aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukáš Lalinský <lukas@oxygene.sk>2015-10-12 14:30:00 +0200
committerLukáš Lalinský <lukas@oxygene.sk>2015-10-12 14:30:00 +0200
commit153820bf12df9ebafbfaea702209eb03b68367ac (patch)
treead0c5add26c9d6a1536150804c4320c379b8a9c2
parentab30ec3a6fc22a58261b1fab3882a0b6f15fa16a (diff)
parent29be00dc5938cfaf7cf93d287d75b7d405f27dc3 (diff)
Merge pull request #669 from pokowaka/bad_access
Fixes access violation
-rw-r--r--taglib/mp4/mp4tag.cpp6
-rw-r--r--tests/test_mp4.cpp8
2 files changed, 11 insertions, 3 deletions
diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp
index abfdbb42..1c188720 100644
--- a/taglib/mp4/mp4tag.cpp
+++ b/taglib/mp4/mp4tag.cpp
@@ -917,7 +917,7 @@ PropertyMap MP4::Tag::setProperties(const PropertyMap &props)
for(; it != props.end(); ++it) {
if(reverseKeyMap.contains(it->first)) {
String name = reverseKeyMap[it->first];
- if(it->first == "TRACKNUMBER" || it->first == "DISCNUMBER") {
+ if((it->first == "TRACKNUMBER" || it->first == "DISCNUMBER") && it->second.size() > 0) {
int first = 0, second = 0;
StringList parts = StringList::split(it->second.front(), "/");
if(parts.size() > 0) {
@@ -928,11 +928,11 @@ PropertyMap MP4::Tag::setProperties(const PropertyMap &props)
d->items[name] = MP4::Item(first, second);
}
}
- else if(it->first == "BPM") {
+ else if(it->first == "BPM" && it->second.size() > 0) {
int value = it->second.front().toInt();
d->items[name] = MP4::Item(value);
}
- else if(it->first == "COMPILATION") {
+ else if(it->first == "COMPILATION" && it->second.size() > 0) {
bool value = (it->second.front().toInt() != 0);
d->items[name] = MP4::Item(value);
}
diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp
index 78e1badf..6841c43f 100644
--- a/tests/test_mp4.cpp
+++ b/tests/test_mp4.cpp
@@ -305,6 +305,14 @@ public:
CPPUNIT_ASSERT(f.tag()->contains("cpil"));
CPPUNIT_ASSERT_EQUAL(false, f.tag()->item("cpil").toBool());
CPPUNIT_ASSERT_EQUAL(StringList("0"), tags["COMPILATION"]);
+
+ // Empty properties do not result in access violations
+ // when converting integers
+ tags["TRACKNUMBER"] = StringList();
+ tags["DISCNUMBER"] = StringList();
+ tags["BPM"] = StringList();
+ tags["COMPILATION"] = StringList();
+ f.setProperties(tags);
}
void testFuzzedFile()