libFLAC++/metadata.cpp: Fix undefined behaviour
authorErik de Castro Lopo <erikd@mega-nerd.com>
Mon, 31 Aug 2015 14:46:32 +0000 (00:46 +1000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Mon, 31 Aug 2015 14:46:42 +0000 (00:46 +1000)
src/libFLAC++/metadata.cpp

index 49dd35a..2293082 100644 (file)
@@ -812,7 +812,8 @@ namespace FLAC {
                                entry_.length += field_name_length_;
                                memcpy(entry_.entry + entry_.length, "=", 1);
                                entry_.length += 1;
-                               memcpy(entry_.entry + entry_.length, field_value_, field_value_length_);
+                               if (field_value_length_ > 0)
+                                       memcpy(entry_.entry + entry_.length, field_value_, field_value_length_);
                                entry_.length += field_value_length_;
                                entry_.entry[entry_.length] = '\0';
                                is_valid_ = true;