Commit d4729e97800e619183519050213a183d39e11fe3

Authored by Bram Veldhoen
1 parent 46b0d40d

Fix SEGV and tests.

src/command.cpp
... ... @@ -167,7 +167,11 @@ template<class ReplyT>
167 167 bool Command<ReplyT>::checkErrorReply() {
168 168  
169 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 175 logger_.error() << cmd() << ": " << last_error_;
172 176 reply_status_ = ERROR_REPLY;
173 177 return true;
... ...
test/test.cpp
... ... @@ -51,7 +51,6 @@ protected:
51 51  
52 52 virtual ~RedoxTest()
53 53 {
54   - rdx.disconnect();
55 54 }
56 55  
57 56 // CV and counter to wait for async commands to complete
... ... @@ -218,6 +217,7 @@ TEST_F(RedoxTest, Loop) {
218 217 }
219 218  
220 219 TEST_F(RedoxTest, GetSetError) {
  220 + connect();
221 221 rdx.command<string>({"SET", "redox_test:a", "apple"}, print_and_check<string>("OK"));
222 222 rdx.command<int>({"GET", "redox_test:a"}, print_and_check_error<int>(3));
223 223 wait_for_replies();
... ... @@ -253,6 +253,7 @@ TEST_F(RedoxTest, IncrSync) {
253 253 }
254 254  
255 255 TEST_F(RedoxTest, GetSetSyncError) {
  256 + connect();
256 257 print_and_check_sync<string>(rdx.commandSync<string>({"SET", "redox_test:a", "apple"}), "OK");
257 258 print_and_check_error_sync<int>(rdx.commandSync<int>({"GET", "redox_test:a"}), 3);
258 259 rdx.disconnect();
... ...