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 6fa3b3d commit c3bd9de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/nanovg.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@ NVGcontext* nvgCreateInternal(NVGparams* params)
FONSparams fontParams;
NVGcontext* ctx = (NVGcontext*)malloc(sizeof(NVGcontext));
int i;
if (ctx == NULL) goto error;
if (ctx == NULL) {
if (ctx->params.userPtr)
free(ctx->params.userPtr);
goto error;
}
memset(ctx, 0, sizeof(NVGcontext));

ctx->params = *params;
Expand Down
1 change: 0 additions & 1 deletion src/nanovg_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,6 @@ NVGcontext* nvgCreateGLES3(int flags)

error:
// 'gl' is freed by nvgDeleteInternal.
if (ctx != NULL) nvgDeleteInternal(ctx);
return NULL;
}

Expand Down

0 comments on commit c3bd9de

Please sign in to comment.