Skip to content

Commit 7ab27ed

Browse files
authored
Merge pull request #38 from Dargun/issue-37
2 parents 531f741 + 9df81db commit 7ab27ed

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Boost::ASIO low-level redis client (connector)
1919

2020
## Changelog
2121

22+
### 0.09
23+
- [bugfix] critical bug in protcol serialization on empty values
24+
2225
### 0.08
2326
- relaxed c++ compiler requirements: c++11 can be used instead of c++14
2427

@@ -764,6 +767,7 @@ MIT
764767
- [Vinnie Falco](https://github.com/vinniefalco)
765768
- [Stephen Coleman](https://github.com/omegacoleman)
766769
- [maxtorm miximtor](https://github.com/miximtor)
770+
- [Ronny Nowak](https://github.com/dargun)
767771

768772
## See also
769773
- https://github.com/Cylix/cpp_redis

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)