mirror of
https://github.com/memononen/nanovg
synced 2026-09-26 16:19:07 +03:00
fix error handling
This commit is contained in:
parent
6fa3b3d519
commit
1a3fe41b1e
2 changed files with 6 additions and 3 deletions
|
|
@ -288,7 +288,12 @@ NVGcontext* nvgCreateInternal(NVGparams* params)
|
|||
FONSparams fontParams;
|
||||
NVGcontext* ctx = (NVGcontext*)malloc(sizeof(NVGcontext));
|
||||
int i;
|
||||
if (ctx == NULL) goto error;
|
||||
if (ctx == NULL) {
|
||||
// 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));
|
||||
|
||||
ctx->params = *params;
|
||||
|
|
|
|||
|
|
@ -1589,8 +1589,6 @@ NVGcontext* nvgCreateGLES3(int flags)
|
|||
return ctx;
|
||||
|
||||
error:
|
||||
// 'gl' is freed by nvgDeleteInternal.
|
||||
if (ctx != NULL) nvgDeleteInternal(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue