Skip to content

Commit b664e3f

Browse files
committed
fix error handling
1 parent fc4d2a1 commit b664e3f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/nanovg.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ NVGcontext* nvgCreateInternal(NVGparams* params)
288288
FONSparams fontParams;
289289
NVGcontext* ctx = (NVGcontext*)malloc(sizeof(NVGcontext));
290290
int i;
291-
if (ctx == NULL) goto error;
291+
if (ctx == NULL) {
292+
if (ctx->params.userPtr)
293+
free(ctx->params.userPtr);
294+
goto error;
295+
}
292296
memset(ctx, 0, sizeof(NVGcontext));
293297

294298
ctx->params = *params;

src/nanovg_gl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ NVGcontext* nvgCreateGLES3(int flags)
15891589
return ctx;
15901590

15911591
error:
1592-
if (gl != NULL) free(gl);
1592+
// 'gl' is freed by nvgDeleteInternal.
15931593
return NULL;
15941594
}
15951595

0 commit comments

Comments
 (0)