Skip to content

Commit

Permalink
fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lieff committed May 17, 2018
1 parent c3bd9de commit b39c6e1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/nanovg.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,10 @@ NVGcontext* nvgCreateInternal(NVGparams* params)
NVGcontext* ctx = (NVGcontext*)malloc(sizeof(NVGcontext));
int i;
if (ctx == NULL) {
if (ctx->params.userPtr)
free(ctx->params.userPtr);
goto error;
// Call renderer delete explicitly. Context is not initialized yet, so we cannot call nvgDeleteInternal() which usually calls the function.
if (params->renderDelete != NULL)
params->renderDelete(params->userPtr);
return NULL;
}
memset(ctx, 0, sizeof(NVGcontext));

Expand Down

0 comments on commit b39c6e1

Please sign in to comment.