Commit d4729e97800e619183519050213a183d39e11fe3
1 parent
46b0d40d
Fix SEGV and tests.
Showing
2 changed files
with
7 additions
and
2 deletions
src/command.cpp
| @@ -167,7 +167,11 @@ template<class ReplyT> | @@ -167,7 +167,11 @@ template<class ReplyT> | ||
| 167 | bool Command<ReplyT>::checkErrorReply() { | 167 | bool Command<ReplyT>::checkErrorReply() { |
| 168 | 168 | ||
| 169 | if (reply_obj_->type == REDIS_REPLY_ERROR) { | 169 | if (reply_obj_->type == REDIS_REPLY_ERROR) { |
| 170 | - last_error_ = reply_obj_->str; | 170 | + if (0 != reply_obj_->str) |
| 171 | + { | ||
| 172 | + last_error_ = reply_obj_->str; | ||
| 173 | + } | ||
| 174 | + | ||
| 171 | logger_.error() << cmd() << ": " << last_error_; | 175 | logger_.error() << cmd() << ": " << last_error_; |
| 172 | reply_status_ = ERROR_REPLY; | 176 | reply_status_ = ERROR_REPLY; |
| 173 | return true; | 177 | return true; |
test/test.cpp
| @@ -51,7 +51,6 @@ protected: | @@ -51,7 +51,6 @@ protected: | ||
| 51 | 51 | ||
| 52 | virtual ~RedoxTest() | 52 | virtual ~RedoxTest() |
| 53 | { | 53 | { |
| 54 | - rdx.disconnect(); | ||
| 55 | } | 54 | } |
| 56 | 55 | ||
| 57 | // CV and counter to wait for async commands to complete | 56 | // CV and counter to wait for async commands to complete |
| @@ -218,6 +217,7 @@ TEST_F(RedoxTest, Loop) { | @@ -218,6 +217,7 @@ TEST_F(RedoxTest, Loop) { | ||
| 218 | } | 217 | } |
| 219 | 218 | ||
| 220 | TEST_F(RedoxTest, GetSetError) { | 219 | TEST_F(RedoxTest, GetSetError) { |
| 220 | + connect(); | ||
| 221 | rdx.command<string>({"SET", "redox_test:a", "apple"}, print_and_check<string>("OK")); | 221 | rdx.command<string>({"SET", "redox_test:a", "apple"}, print_and_check<string>("OK")); |
| 222 | rdx.command<int>({"GET", "redox_test:a"}, print_and_check_error<int>(3)); | 222 | rdx.command<int>({"GET", "redox_test:a"}, print_and_check_error<int>(3)); |
| 223 | wait_for_replies(); | 223 | wait_for_replies(); |
| @@ -253,6 +253,7 @@ TEST_F(RedoxTest, IncrSync) { | @@ -253,6 +253,7 @@ TEST_F(RedoxTest, IncrSync) { | ||
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | TEST_F(RedoxTest, GetSetSyncError) { | 255 | TEST_F(RedoxTest, GetSetSyncError) { |
| 256 | + connect(); | ||
| 256 | print_and_check_sync<string>(rdx.commandSync<string>({"SET", "redox_test:a", "apple"}), "OK"); | 257 | print_and_check_sync<string>(rdx.commandSync<string>({"SET", "redox_test:a", "apple"}), "OK"); |
| 257 | print_and_check_error_sync<int>(rdx.commandSync<int>({"GET", "redox_test:a"}), 3); | 258 | print_and_check_error_sync<int>(rdx.commandSync<int>({"GET", "redox_test:a"}), 3); |
| 258 | rdx.disconnect(); | 259 | rdx.disconnect(); |