Fixed a looming memory corruption bug.
malloc does not initialize the memory to zero, so sass_context *ctx = sass_new_context() will create a context with a random value in ctx->output_string. If sass_free_context(ctx) was called immediately thereafter, ctx->output_string would have a random value and the result of the free(ctx->output_string) would be undefined. In the worst case, this corrupts the heap and the process dies much much later. Also, free isn't delete and mustn't be called with a NULL pointer.
Showing
Please
register
or
sign in
to comment