Skip to content

Commit

Permalink
Fix possible segfault with strdup (undefined behavior)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Dec 20, 2014
1 parent 67e706c commit 9852e41
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sass_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ extern "C" {
void sass_option_set_##option (struct Sass_Options* options, type option) { options->option = option; }
#define IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(type, option) \
type sass_option_get_##option (struct Sass_Options* options) { return options->option; } \
void sass_option_set_##option (struct Sass_Options* options, type option) { free(options->option); options->option = strdup(option); }
void sass_option_set_##option (struct Sass_Options* options, type option) \
{ free(options->option); options->option = option ? strdup(option) : 0; }

#define IMPLEMENT_SASS_CONTEXT_GETTER(type, option) \
type sass_context_get_##option (struct Sass_Context* ctx) { return ctx->option; }
Expand Down

0 comments on commit 9852e41

Please sign in to comment.