Memory leak in layer->name
Brought to you by:
spetm,
thepurlieu
valgrind found a memory leak around the layer name. In gerber.c, there is this line:
state->layer->name = gerb_fgetstring(fd, '*');
There is no corresponding free.
The fix is to call g_free in the destroy function. Also, because the data is not initialized, it's best to set it to NULL when creating a layer so that a layer without a name will not have some garbage value in the name. g_free(NULL) is a no-op.
Here's a fix, tested in valgrind to show that it solves the problem. g_free(NULL) was also tested to be safe and the setting of layer->name = NULL was also tested to be necessary.
Last edit: Eyal 2019-10-31