mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-19 18:39:26 +00:00
Do not assert error codes on Hiredis backend
We cannot assume that Redis is never going to return an error code; when Reddit fails, we cannot crash our library, we need to handle the crash gracefully. Signed-off-by: Vicent Marti <tanoku@gmail.com>
This commit is contained in:
parent
8a64bc292c
commit
5868cd02b7
@ -52,7 +52,6 @@ int hiredis_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backe
|
|||||||
|
|
||||||
reply = redisCommand(backend->db, "HMGET %b %s %s", oid->id, GIT_OID_RAWSZ,
|
reply = redisCommand(backend->db, "HMGET %b %s %s", oid->id, GIT_OID_RAWSZ,
|
||||||
"type", "size");
|
"type", "size");
|
||||||
assert(reply->type != REDIS_REPLY_ERROR);
|
|
||||||
|
|
||||||
if (reply->type == REDIS_REPLY_ARRAY) {
|
if (reply->type == REDIS_REPLY_ARRAY) {
|
||||||
if (reply->element[0]->type != REDIS_REPLY_NIL &&
|
if (reply->element[0]->type != REDIS_REPLY_NIL &&
|
||||||
@ -83,7 +82,7 @@ int hiredis_backend__read(void **data_p, size_t *len_p, git_otype *type_p, git_o
|
|||||||
|
|
||||||
reply = redisCommand(backend->db, "HMGET %b %s %s %s", oid->id, GIT_OID_RAWSZ,
|
reply = redisCommand(backend->db, "HMGET %b %s %s %s", oid->id, GIT_OID_RAWSZ,
|
||||||
"type", "size", "data");
|
"type", "size", "data");
|
||||||
assert(reply->type != REDIS_REPLY_ERROR);
|
|
||||||
if (reply->type == REDIS_REPLY_ARRAY) {
|
if (reply->type == REDIS_REPLY_ARRAY) {
|
||||||
if (reply->element[0]->type != REDIS_REPLY_NIL &&
|
if (reply->element[0]->type != REDIS_REPLY_NIL &&
|
||||||
reply->element[1]->type != REDIS_REPLY_NIL &&
|
reply->element[1]->type != REDIS_REPLY_NIL &&
|
||||||
@ -119,8 +118,7 @@ int hiredis_backend__exists(git_odb_backend *_backend, const git_oid *oid) {
|
|||||||
found = 0;
|
found = 0;
|
||||||
|
|
||||||
reply = redisCommand(backend->db, "exists %b", oid->id, GIT_OID_RAWSZ);
|
reply = redisCommand(backend->db, "exists %b", oid->id, GIT_OID_RAWSZ);
|
||||||
assert(reply->type == REDIS_REPLY_ERROR);
|
if (reply->type != REDIS_REPLY_NIL && reply->type != REDIS_REPLY_ERROR)
|
||||||
if (reply->type != REDIS_REPLY_NIL)
|
|
||||||
found = 1;
|
found = 1;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user