Skip to content

Commit

Permalink
Fixes:
Browse files Browse the repository at this point in the history
- memory leaks in connection.c::RedisConnection_sendCommand()
  and resp.c::RedisObject_RESP_array()
- illegal read in object.c::RedisObject_parseSimpleString()
- incorrect assert in object.c::RedisObject_parseBulkString()
  • Loading branch information
rpj committed Aug 17, 2019
1 parent b8fe7f3 commit 0b4d1ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RedisObject_t RedisConnection_sendCommand(RedisConnection_t conn, RedisObject_t
rObj = RedisConnection_getNextObject(conn);
}

free(cmdRESP);
return rObj;
}

Expand Down Expand Up @@ -68,4 +69,4 @@ RedisObject_t RedisConnection_getNextObject(RedisConnection_t conn)
}

return rObj;
}
}
3 changes: 1 addition & 2 deletions src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RedisObject_t RedisObject_parseSimpleString(RedisConnection_t conn)
// is this needed? consumes the newline, but doesn't getNextObject do that already?
if (readBuf[readOffset] != '\n')
++readOffset;
} while (readBuf[readOffset - 1] != '\r');
} while (readOffset == 0 || readBuf[readOffset - 1] != '\r');

readBuf[readOffset - 1] = '\0';
rObj.obj = realloc(readBuf, readOffset);
Expand All @@ -56,7 +56,6 @@ RedisObject_t RedisObject_parseBulkString(RedisConnection_t conn)
if (len != -1)
{
RedisObject_t strObj = RedisObject_parseSimpleString(conn);
assert(strObj.obj && len == strlen((char *)strObj.obj));
rObj.obj = strObj.obj;
}

Expand Down
1 change: 1 addition & 0 deletions src/resp.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ char *RedisObject_RESP_array(RedisObject_t obj)
{
memcpy(copyPtr, constRESPs[i].RESP, constRESPs[i].length);
copyPtr += constRESPs[i].length;
free(constRESPs[i].RESP);
}

free(constRESPs);
Expand Down

0 comments on commit 0b4d1ea

Please sign in to comment.