afh: Unmap the audio file on errors.
authorAndre Noll <maan@systemlinux.org>
Sun, 27 Oct 2013 10:24:43 +0000 (11:24 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 15 Jan 2015 20:57:28 +0000 (21:57 +0100)
If compute_afhi() returns negative we miss to call para_munmap()
to unmap the audio file. This is not a serious bug since we exit
anyway in this case.

afh.c

diff --git a/afh.c b/afh.c
index d06e442..49629cb 100644 (file)
--- a/afh.c
+++ b/afh.c
@@ -102,16 +102,15 @@ int main(int argc, char **argv)
                }
                ret = compute_afhi(conf.inputs[i], audio_file_data, audio_file_size,
                        fd, &afhi);
-               if (ret < 0)
-                       goto out;
-
-               audio_format_num = ret;
-               printf("File %d: %s\n", i + 1, conf.inputs[i]);
-               print_info(audio_format_num, &afhi);
-               if (conf.chunk_table_given)
-                       print_chunk_table(&afhi);
-               printf("\n");
-               clear_afhi(&afhi);
+               if (ret >= 0) {
+                       audio_format_num = ret;
+                       printf("File %d: %s\n", i + 1, conf.inputs[i]);
+                       print_info(audio_format_num, &afhi);
+                       if (conf.chunk_table_given)
+                               print_chunk_table(&afhi);
+                       printf("\n");
+                       clear_afhi(&afhi);
+               }
                ret2 = para_munmap(audio_file_data, audio_file_size);
                if (ret2 < 0 && ret >= 0)
                        ret = ret2;