fix bug where test would fail if libFLAC not built with ogg support
[platform/upstream/flac.git] / src / test_libFLAC / metadata_manip.c
index e5ba9b3..6a1cc52 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <stdio.h>
 #include <stdlib.h> /* for malloc() */
+#include <string.h> /* for memcpy()/memset() */
 #if defined _MSC_VER || defined __MINGW32__
 #include <sys/utime.h> /* for utime() */
 #include <io.h> /* for chmod() */
@@ -608,6 +609,7 @@ static FLAC__bool generate_file_(FLAC__bool include_extras, FLAC__bool is_ogg)
                return die_("creating the encoded file");
 
        free(vorbiscomment.data.vorbis_comment.vendor_string.entry);
+       free(picture.data.picture.mime_type);
 
        return true;
 }
@@ -2110,15 +2112,17 @@ FLAC__bool test_metadata_file_manipulation()
        if(!test_level_2_misc_(/*is_ogg=*/false))
                return false;
 
-       if(!test_level_2_(/*filename_based=*/true, /*is_ogg=*/true)) /* filename-based */
-               return false;
-       if(!test_level_2_(/*filename_based=*/false, /*is_ogg=*/true)) /* callback-based */
-               return false;
+       if(FLAC_API_SUPPORTS_OGG_FLAC) {
+               if(!test_level_2_(/*filename_based=*/true, /*is_ogg=*/true)) /* filename-based */
+                       return false;
+               if(!test_level_2_(/*filename_based=*/false, /*is_ogg=*/true)) /* callback-based */
+                       return false;
 #if 0
-       /* when ogg flac write is supported, will have to add this: */
-       if(!test_level_2_misc_(/*is_ogg=*/true))
-               return false;
+               /* when ogg flac write is supported, will have to add this: */
+               if(!test_level_2_misc_(/*is_ogg=*/true))
+                       return false;
 #endif
+       }
 
        return true;
 }