]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Fix com_add segfault.
authorAndre Noll <maan@systemlinux.org>
Thu, 13 Sep 2007 19:55:46 +0000 (21:55 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 13 Sep 2007 19:55:46 +0000 (21:55 +0200)
We call free(obj.data) unconditionally on errors, but is is not set to NULL.
Also, return always success in add_one_audio_file() in order to continue the
loop.

aft.c
vss.c

diff --git a/aft.c b/aft.c
index 82724c3d10ca578bde9e662803571c5fee333e49..8473bc9b012b275518e056f2631222eaa954b462 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -1402,7 +1402,7 @@ static int add_one_audio_file(const char *arg, const void *private_data)
        const struct private_add_data *pad = private_data;
        struct audio_format_info afhi, *afhi_ptr = NULL;
        struct osl_row *pb = NULL, *hs = NULL; /* path brother/hash sister */
-       struct osl_object map, obj, query, result;
+       struct osl_object map, obj = {.data = NULL}, query, result;
        char *path;
        HASH_TYPE hash[HASH_SIZE];
 
@@ -1477,7 +1477,7 @@ out_free:
        free(path);
        if (afhi_ptr)
                free(afhi_ptr->chunk_table);
-       return ret;
+       return 1; /* it's not an error if not all files could be added */
 }
 
 int com_add(int fd, int argc, char * const * const argv)
diff --git a/vss.c b/vss.c
index a6d3dfc03469095e8b5d398bf79d930c44133ca9..2de7a30c7bdc328cc82041135918a70da02c9578 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -278,6 +278,7 @@ int compute_afhi(const char *path, char *data, size_t size,
                ret = afl[i].get_file_info(data, size, afhi);
                if (ret >= 0)
                        return i;
+               PARA_WARNING_LOG("%s\n", PARA_STRERROR(-ret));
        }
        return -E_AUDIO_FORMAT;
 }