Skip to content

Commit dd0c584

Browse files
committed
fix #37
1 parent 531f741 commit dd0c584

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/bredis/impl/protocol.ipp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ inline std::size_t size_for_int(std::size_t arg) {
442442
++r;
443443
arg /= 10;
444444
}
445-
return r;
445+
return std::max<size_t>(1, r); /* if r == 0 we clamp max to 1 to allow minimum containing "0" as char */
446446
}
447447

448448
inline std::size_t command_size(const single_command_t &cmd) {
@@ -477,9 +477,11 @@ inline void Protocol::serialize(DynamicBuffer &buff,
477477
it += bytes;
478478
total += bytes;
479479

480-
buffer_copy(it, buffer(arg.data(), arg.size()));
481-
it += arg.size();
482-
total += arg.size();
480+
if(!arg.empty()) {
481+
buffer_copy(it, buffer(arg.data(), arg.size()));
482+
it += arg.size();
483+
total += arg.size();
484+
}
483485

484486
buffer_copy(it, buffer("\r\n", terminator.size));
485487
total += terminator.size;

0 commit comments

Comments
 (0)