annolinux / gnome-mplayer

Automatically exported from code.google.com/p/gnome-mplayer
0 stars 0 forks source link

found a memory leak in file support.c #217

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. cppcheck -q -a -v -f -j3 gnome-mplayer-read-only/ .
2. output: [gnome-mplayer-read-only/src/support.c:1232]: (all) Memory leak: ret

This memory leak was detected by using the static code analyis tool
cppcheck. It prints a waring about a memory leak at file
src/support.c at line 1232. Take a look at the code.
// ....
    MetaData *ret = NULL;
#ifdef GIO_ENABLED
    GFile *file;
#endif
    if (device_name(uri)) {
        name = g_strdup(uri);
        if (ret == NULL)
            ret = (MetaData *) g_new0(MetaData, 1);

    } else {
#ifdef GIO_ENABLED
        file = g_file_new_for_uri(uri);
        if (file != NULL) {
            name = g_file_get_path(file);
            basename = g_file_get_basename(file);
        }
#else
        name = g_filename_from_uri(uri, NULL, NULL);
        basename = g_filename_display_basename(name);
#endif
    }

       if (name == NULL)
1232        return NULL;

A possible solution might be to append  g_free(ret); at the end before the
return;
....
       if (name == NULL)
       {
    g_free(ret);
        return NULL;
       }
.....

Best regards

Ettl Martin

What version of the product are you using?
 gnome-mplayer-read-only , current svn head

On what operating system?
Ubuntu-Linux, Jaunty 9.04, 32-Bit

Original issue reported on code.google.com by ettl.mar...@gmail.com on 27 Jun 2009 at 4:11

GoogleCodeExporter commented 9 years ago
Fixed... Also found another right there and fixed that one too.

Original comment by kdeko...@gmail.com on 29 Jun 2009 at 6:42