summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sesterhenn <eric.sesterhenn@lsexperts.de>2009-11-05 10:06:50 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-06 00:26:28 +0100
commitec3c68c0f52c2ea03c07372e979c3832987fbc23 (patch)
treeccdeafe999627df21dba881b76e61863c084ce85
parent79dafb193f78a8efda7b38e0129486f72775f733 (diff)
Fix fd leak in libcanberra
hi, while playing around with cppcheck, the tool noticed that there is a file descriptor leak: [libcanberra-0.22/src/gstreamer.c:285]: (error) Resource leak: fd Attached patch fixes the leak in two places. Regards, Eric
-rw-r--r--src/gstreamer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gstreamer.c b/src/gstreamer.c
index 5ff835c..f797984 100644
--- a/src/gstreamer.c
+++ b/src/gstreamer.c
@@ -277,12 +277,15 @@ static int ca_gst_sound_file_open(ca_sound_file **_f, const char *fn) {
if ((fd = open(fn, O_RDONLY)) == -1)
return errno == ENOENT ? CA_ERROR_NOTFOUND : CA_ERROR_SYSTEM;
- if (!(f = ca_new0(ca_sound_file, 1)))
+ if (!(f = ca_new0(ca_sound_file, 1))) {
+ close(fd);
return CA_ERROR_OOM;
+ }
if (!(f->fdsrc = gst_element_factory_make("fdsrc", NULL))) {
+ close(fd);
ca_free(f);
- return CA_ERROR_OOM;
+ return CA_ERROR_OOM;
}
g_object_set(GST_OBJECT(f->fdsrc), "fd", fd, NULL);