CodeQL MemoryMayNotBeFreed.ql grTCairo1.c GrTCairoPlotSVG()
created use of 'alloc' local variable to track when an allocation occurred so exit path logic is more straight forward for compiler/analyser to see potential optimisations. the previous version was probably working just fine
This commit is contained in:
parent
e565b4c360
commit
a764fdbbd1
|
|
@ -356,6 +356,7 @@ GrTCairoPlotSVG (char *filename, MagWindow *mw)
|
||||||
{
|
{
|
||||||
int screenw, screenh;
|
int screenw, screenh;
|
||||||
char *fileptr;
|
char *fileptr;
|
||||||
|
char *alloc = NULL;
|
||||||
cairo_surface_t *wind_surface;
|
cairo_surface_t *wind_surface;
|
||||||
cairo_t *wind_context;
|
cairo_t *wind_context;
|
||||||
|
|
||||||
|
|
@ -373,7 +374,7 @@ GrTCairoPlotSVG (char *filename, MagWindow *mw)
|
||||||
fileptr = filename;
|
fileptr = filename;
|
||||||
if (strchr(filename, '.') == NULL)
|
if (strchr(filename, '.') == NULL)
|
||||||
{
|
{
|
||||||
fileptr = mallocMagic(strlen(filename) + 5);
|
fileptr = alloc = mallocMagic(strlen(filename) + 5);
|
||||||
sprintf(fileptr, "%s.svg", filename);
|
sprintf(fileptr, "%s.svg", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -387,7 +388,7 @@ GrTCairoPlotSVG (char *filename, MagWindow *mw)
|
||||||
cairo_svg_surface_restrict_to_version(tcairodata->surface,
|
cairo_svg_surface_restrict_to_version(tcairodata->surface,
|
||||||
CAIRO_SVG_VERSION_1_2);
|
CAIRO_SVG_VERSION_1_2);
|
||||||
|
|
||||||
if (fileptr != filename) freeMagic(fileptr);
|
if (alloc) freeMagic(alloc);
|
||||||
|
|
||||||
tcairodata->context = cairo_create(tcairodata->surface);
|
tcairodata->context = cairo_create(tcairodata->surface);
|
||||||
WindRedisplay(mw);
|
WindRedisplay(mw);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue