From d4729e97800e619183519050213a183d39e11fe3 Mon Sep 17 00:00:00 2001 From: Bram Veldhoen Date: Wed, 3 Jun 2015 16:43:59 +0200 Subject: [PATCH] Fix SEGV and tests. --- src/command.cpp | 6 +++++- test/test.cpp | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index 45803e4..9302c05 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -167,7 +167,11 @@ template bool Command::checkErrorReply() { if (reply_obj_->type == REDIS_REPLY_ERROR) { - last_error_ = reply_obj_->str; + if (0 != reply_obj_->str) + { + last_error_ = reply_obj_->str; + } + logger_.error() << cmd() << ": " << last_error_; reply_status_ = ERROR_REPLY; return true; diff --git a/test/test.cpp b/test/test.cpp index e14fec9..f422a51 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -51,7 +51,6 @@ protected: virtual ~RedoxTest() { - rdx.disconnect(); } // CV and counter to wait for async commands to complete @@ -218,6 +217,7 @@ TEST_F(RedoxTest, Loop) { } TEST_F(RedoxTest, GetSetError) { + connect(); rdx.command({"SET", "redox_test:a", "apple"}, print_and_check("OK")); rdx.command({"GET", "redox_test:a"}, print_and_check_error(3)); wait_for_replies(); @@ -253,6 +253,7 @@ TEST_F(RedoxTest, IncrSync) { } TEST_F(RedoxTest, GetSetSyncError) { + connect(); print_and_check_sync(rdx.commandSync({"SET", "redox_test:a", "apple"}), "OK"); print_and_check_error_sync(rdx.commandSync({"GET", "redox_test:a"}), 3); rdx.disconnect(); -- libgit2 0.21.4