shithub: mp3dec

Download patch

ref: 93ef385153cd360f4874648ceb0f3916b97c4a41
parent: f3b33b079054571a7604289a604c76bd0ebef463
author: lieff <[email protected]>
date: Tue Feb 13 18:20:01 EST 2018

small fixes

--- a/minimp3_test.c
+++ b/minimp3_test.c
@@ -74,7 +74,7 @@
                     int MSEtemp = abs((int)pcm[i] - (int)(((short*)buf_ref)[i]));
                     if (MSEtemp > maxdiff)
                         maxdiff = MSEtemp;
-                    MSE += MSEtemp*MSEtemp;
+                    MSE += (float)MSEtemp*(float)MSEtemp;
                 }
                 buf_ref  += samples*info.channels*2;
                 ref_size -= samples*info.channels*2;
@@ -136,7 +136,7 @@
             wave_out = 1;
 #endif
     }
-    FILE *file_ref = fopen(ref_file_name, "rb");
+    FILE *file_ref = ref_file_name ? fopen(ref_file_name, "rb") : NULL;
     unsigned char *buf_ref = preload(file_ref, &ref_size);
     if (file_ref)
         fclose(file_ref);
@@ -153,6 +153,11 @@
     FILE *file_mp3 = fopen(input_file_name, "rb");
     unsigned char *buf_mp3 = preload(file_mp3, &mp3_size);
     fclose(file_mp3);
+    if (!buf_mp3 || !mp3_size)
+    {
+        printf("error: no mp3 data\n");
+        return 1;
+    }
     decode_file(buf_mp3, mp3_size, buf_ref, ref_size, file_out, wave_out);
     if (buf_mp3)
         free(buf_mp3);
--- a/scripts/fuzz_libfuzzer.sh
+++ b/scripts/fuzz_libfuzzer.sh
@@ -4,4 +4,5 @@
 
 pushd $CUR_DIR/..
 
-clang-5.0 -g -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard -DFUZZ -DLIBFUZZER -o minimp3_libfuzz minimp3_test.c -lFuzzer -lstdc++ -lm
\ No newline at end of file
+clang-5.0 -g -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard -DFUZZ -DLIBFUZZER -o minimp3_libfuzz minimp3_test.c -lFuzzer -lstdc++ -lm
+./minimp3_libfuzz -max_len=1024 vectors/fuzz
\ No newline at end of file
binary files a/vectors/l3-nonstandard-big-iscf.pcm b/vectors/l3-nonstandard-big-iscf.pcm differ