From f01d7d230b1835ab035a5130e2a39f05f0aabdf5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 15 Dec 2009 18:59:03 +0100 Subject: input/file: don't fall back to parent directory This code has never made any sense, and has broken some of the archive plugin. --- src/input/file_input_plugin.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'src/input') diff --git a/src/input/file_input_plugin.c b/src/input/file_input_plugin.c index 64a4030a..bda1777a 100644 --- a/src/input/file_input_plugin.c +++ b/src/input/file_input_plugin.c @@ -36,25 +36,14 @@ input_file_open(struct input_stream *is, const char *filename) int fd, ret; struct stat st; - char* pathname = g_strdup(filename); - if (filename[0] != '/') - { - g_free(pathname); return false; - } - if (stat(filename, &st) < 0) { - char* slash = strrchr(pathname, '/'); - *slash = '\0'; - } - - fd = open(pathname, O_RDONLY); + fd = open(filename, O_RDONLY); if (fd < 0) { is->error = errno; g_debug("Failed to open \"%s\": %s", - pathname, g_strerror(errno)); - g_free(pathname); + filename, g_strerror(errno)); return false; } @@ -64,15 +53,13 @@ input_file_open(struct input_stream *is, const char *filename) if (ret < 0) { is->error = errno; close(fd); - g_free(pathname); return false; } if (!S_ISREG(st.st_mode)) { - g_debug("Not a regular file: %s", pathname); + g_debug("Not a regular file: %s", filename); is->error = EINVAL; close(fd); - g_free(pathname); return false; } @@ -86,8 +73,6 @@ input_file_open(struct input_stream *is, const char *filename) is->data = GINT_TO_POINTER(fd); is->ready = true; - g_free(pathname); - return true; } -- cgit v1.2.3 From 2234d491b7c1a8cbea0cb4e444fc72c37aec5016 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 15 Dec 2009 19:31:50 +0100 Subject: input/archive: close the archive file on error Fixed memory leak in error handler. --- NEWS | 1 + src/input/archive_input_plugin.c | 1 + 2 files changed, 2 insertions(+) (limited to 'src/input') diff --git a/NEWS b/NEWS index 5ef6e21d..6bcf328f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ver 0.15.7 (2009/??/??) * input: - file: don't fall back to parent directory + - archive: fixed memory leak in error handler * tags: - id3: fix ID3v1 charset conversion * decoders: diff --git a/src/input/archive_input_plugin.c b/src/input/archive_input_plugin.c index 6239f429..8e897f0c 100644 --- a/src/input/archive_input_plugin.c +++ b/src/input/archive_input_plugin.c @@ -66,6 +66,7 @@ input_archive_open(struct input_stream *is, const char *pathname) if (!opened) { g_warning("open inarchive file %s failed\n\n",filename); + arplug->close(file); } else { is->ready = true; } -- cgit v1.2.3