Discussion:
[Viking-devel] Possible memory leak in vikmapslayer.c
Kamil Ignacak
2017-06-15 17:30:27 UTC
Permalink
Hi!

I think that I have spotted a minor memory leak in Maps Layer code:
In vikmapslayer.c/maps_layer_how_many_maps() (around line 2266) there is
this block of code:

if ( mdi->redownload == REDOWNLOAD_BAD ) {
/* see if this one is bad or what */
GError *gx = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file ( mdi->filename_buf,
&gx );
if (gx || (!pixbuf)) {
mdi->mapstoget++;
}
break;
// Other download cases already considered or just ignored
}

If I understand correctly, gdk_pixbuf_new_from_file() may allocate a new
pixbuf, but it won't be deallocated anywhere. Am I right here?
Moreover if gdk_pixbuf_new_from_file() fails, then gx is set, but is
never deallocated with g_error_free().

Top level comment for maps_layer_how_many_maps() says "Copied from
maps_layer_download_section", so maybe the problems occur somewhere
else, too, but I didn't verify this.

Best regards,
Kamil

Loading...