Individual reply object functions may be NULL

This commit is contained in:
Pieter Noordhuis 2011-04-03 17:46:59 +02:00
parent b4f85484ea
commit 921150fc8a

View File

@ -271,13 +271,16 @@ static int processLineItem(redisReader *r) {
int len;
if ((p = readLine(r,&len)) != NULL) {
if (r->fn) {
if (cur->type == REDIS_REPLY_INTEGER) {
if (r->fn && r->fn->createInteger)
obj = r->fn->createInteger(cur,readLongLong(p));
else
obj = (void*)REDIS_REPLY_INTEGER;
} else {
/* Type will be error or status. */
if (r->fn && r->fn->createString)
obj = r->fn->createString(cur,p,len);
}
} else {
else
obj = (void*)(size_t)(cur->type);
}
@ -306,15 +309,19 @@ static int processBulkItem(redisReader *r) {
if (len < 0) {
/* The nil object can always be created. */
obj = r->fn ? r->fn->createNil(cur) :
(void*)REDIS_REPLY_NIL;
if (r->fn && r->fn->createNil)
obj = r->fn->createNil(cur);
else
obj = (void*)REDIS_REPLY_NIL;
success = 1;
} else {
/* Only continue when the buffer contains the entire bulk item. */
bytelen += len+2; /* include \r\n */
if (r->pos+bytelen <= r->len) {
obj = r->fn ? r->fn->createString(cur,s+2,len) :
(void*)REDIS_REPLY_STRING;
if (r->fn && r->fn->createString)
obj = r->fn->createString(cur,s+2,len);
else
obj = (void*)REDIS_REPLY_STRING;
success = 1;
}
}
@ -351,12 +358,16 @@ static int processMultiBulkItem(redisReader *r) {
root = (r->ridx == 0);
if (elements == -1) {
obj = r->fn ? r->fn->createNil(cur) :
(void*)REDIS_REPLY_NIL;
if (r->fn && r->fn->createNil)
obj = r->fn->createNil(cur);
else
obj = (void*)REDIS_REPLY_NIL;
moveToNextTask(r);
} else {
obj = r->fn ? r->fn->createArray(cur,elements) :
(void*)REDIS_REPLY_ARRAY;
if (r->fn && r->fn->createArray)
obj = r->fn->createArray(cur,elements);
else
obj = (void*)REDIS_REPLY_ARRAY;
/* Modify task stack when there are more than 0 elements. */
if (elements > 0) {