annolinux / gnome-mplayer

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

found a possible memory leak #203

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. cppcheck -q -a -v -f -j2 gnome-mplayer-0.9.6/
2. [gnome-mplayer-0.9.6/src/support.c:340]: (error) Memory leak: file

The static code analysis tool complained about line 340.
Take a loop at line 340:
.....
    FILE *fp;
    gchar *file = NULL;

    file = g_strndup(uri, 4);
    if (strcmp(file, "file") != 0)
340        return 0;               // FIXME: remote playlists unsuppored
.....

The function returns without freeing the memory.

A possible way to avoid this memory leak is:

    FILE *fp;
    gchar *file = NULL;

    file = g_strndup(uri, 4);
    if (strcmp(file, "file") != 0){
        g_free(file);
        return 0;
       }

What version of the product are you using?
gnome-mplayer-0.9.6

On what operating system?
Ubuntu Linux(Jaunty,32-Bit,g++-4.3.2)

Best regards

Ettl Martin

Original issue reported on code.google.com by ettl.mar...@gmail.com on 15 Jun 2009 at 9:44

GoogleCodeExporter commented 9 years ago
Fixed

Original comment by kdeko...@gmail.com on 15 Jun 2009 at 9:55