From 259bc3a749f5619ca59219e8d7602b8692945113 Mon Sep 17 00:00:00 2001 From: Hayk Date: Sun, 15 Nov 2015 00:02:45 -0800 Subject: [PATCH] Fix bug in subscriber for binary data --- src/subscriber.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/subscriber.cpp b/src/subscriber.cpp index 47815d6..8847357 100644 --- a/src/subscriber.cpp +++ b/src/subscriber.cpp @@ -152,15 +152,17 @@ void Subscriber::subscribeBase(const string cmd_name, const string topic, // Message for subscribe else if ((reply->type == REDIS_REPLY_ARRAY) && (reply->elements == 3)) { char *msg = reply->element[2]->str; + int len = reply->element[2]->len; if (msg && msg_callback) - msg_callback(topic, reply->element[2]->str); + msg_callback(topic, string(msg, len)); } // Message for psubscribe else if ((reply->type == REDIS_REPLY_ARRAY) && (reply->elements == 4)) { - char *msg = reply->element[2]->str; + char *msg = reply->element[3]->str; + int len = reply->element[3]->len; if (msg && msg_callback) - msg_callback(reply->element[2]->str, reply->element[3]->str); + msg_callback(reply->element[2]->str, string(msg, len)); } else -- libgit2 0.21.4