diff --git a/src/value.cpp b/src/value.cpp index 7521cfe1..ab8f284f 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -977,11 +977,10 @@ namespace Exiv2 { // sprintf wants to add the null terminator, so use oversized buffer char temp[9]; - int wrote = sprintf(temp, "%04d%02d%02d", - date_.year, date_.month, date_.day); + int wrote = sprintf(temp, "%04d%02d%02d", date_.year, date_.month, date_.day); assert(wrote == 8); - std::memcpy(buf, temp, 8); - return 8; + std::memcpy(buf, temp, wrote); + return wrote; } const DateValue::Date& DateValue::getDate() const