From 6d5a56308a3a833b08ae0e3692b794fb6122ea60 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 19 Mar 2008 21:51:46 +0100 Subject: [PATCH] Fix use of uninitialized afhi->header_len. In aft's add_one_audio_file() we set the header len and the header offset to zero so that the get_file_info() functions of the audio format handlers that do not use headers don't need to zero these fields. However, this is not the right place to do that as para_afh also calls get_file_info() via compute_afhi() but missed to clear these fields which leads to a segmentation fault. Fix this bug by moving the zeroing to compute_afhi(). --- afh_common.c | 6 +++++- aft.c | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/afh_common.c b/afh_common.c index 4f84334c..feee4c8d 100644 --- a/afh_common.c +++ b/afh_common.c @@ -143,7 +143,11 @@ int guess_audio_format(const char *name) int compute_afhi(const char *path, char *data, size_t size, struct afh_info *afhi) { - int ret, i, format = guess_audio_format(path); + int ret, i, format; + + afhi->header_offset = 0; + afhi->header_len = 0; + format = guess_audio_format(path); if (format >= 0) { ret = afl[format].get_file_info(data, size, afhi); diff --git a/aft.c b/aft.c index 5f5548f0..51e36c8e 100644 --- a/aft.c +++ b/aft.c @@ -1722,8 +1722,6 @@ static int add_one_audio_file(const char *path, const void *private_data) struct osl_object map, obj = {.data = NULL}, query, result = {.data = NULL}; HASH_TYPE hash[HASH_SIZE]; - afhi.header_offset = 0; - afhi.header_len = 0; ret = guess_audio_format(path); if (ret < 0 && !(pad->flags & ADD_FLAG_ALL)) goto out_free; -- 2.39.5