diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-04-08 03:28:38 +0300 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-04-08 03:28:38 +0300 |
commit | 5868cd02b7ff21f848b64ead3d7b0aa62155046e (patch) | |
tree | 14b1e819abf768e0da158f6b7256ae85e27fe120 /src | |
parent | 8a64bc292c36f5af3e42c46712cb449e19dfa125 (diff) | |
download | libgit2-5868cd02b7ff21f848b64ead3d7b0aa62155046e.tar.gz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/backends/hiredis.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/backends/hiredis.c b/src/backends/hiredis.c index ea8322fa7..707412bf6 100644 --- a/src/backends/hiredis.c +++ b/src/backends/hiredis.c @@ -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, "type", "size"); - assert(reply->type != REDIS_REPLY_ERROR); if (reply->type == REDIS_REPLY_ARRAY) { 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, "type", "size", "data"); - assert(reply->type != REDIS_REPLY_ERROR); + if (reply->type == REDIS_REPLY_ARRAY) { if (reply->element[0]->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; reply = redisCommand(backend->db, "exists %b", oid->id, GIT_OID_RAWSZ); - assert(reply->type == REDIS_REPLY_ERROR); - if (reply->type != REDIS_REPLY_NIL) + if (reply->type != REDIS_REPLY_NIL && reply->type != REDIS_REPLY_ERROR) found = 1; |