Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/nanovg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be (ctx->params is not set yet either):

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;
}

// 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;
Expand Down
2 changes: 0 additions & 2 deletions src/nanovg_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1589,8 +1589,6 @@ NVGcontext* nvgCreateGLES3(int flags)
return ctx;

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

Expand Down