Skip to content

Commit be4d971

Browse files
authored
Merge pull request #957 from redboltz/fix_956
Fixed #956.
2 parents fc3de98 + 3feac1f commit be4d971

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/msgpack/v1/unpack.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ inline void unpack_str(unpack_user& u, const char* p, uint32_t l, msgpack::objec
171171
o.via.str.ptr = p;
172172
u.set_referenced(true);
173173
}
174-
else {
174+
else if (l > 0) {
175175
if (l > u.limit().str()) throw msgpack::str_size_overflow("str size overflow");
176176
char* tmp = static_cast<char*>(u.zone().allocate_align(l, MSGPACK_ZONE_ALIGNOF(char)));
177177
std::memcpy(tmp, p, l);
@@ -187,7 +187,7 @@ inline void unpack_bin(unpack_user& u, const char* p, uint32_t l, msgpack::objec
187187
o.via.bin.ptr = p;
188188
u.set_referenced(true);
189189
}
190-
else {
190+
else if (l > 0) {
191191
if (l > u.limit().bin()) throw msgpack::bin_size_overflow("bin size overflow");
192192
char* tmp = static_cast<char*>(u.zone().allocate_align(l, MSGPACK_ZONE_ALIGNOF(char)));
193193
std::memcpy(tmp, p, l);

0 commit comments

Comments
 (0)