aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-10-01 22:51:38 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-10-01 22:51:38 +0000
commitdbd4abf0ff534013f998271250434a9df12de353 (patch)
tree98b983b1176072ee78427d5b5c636acb61322433
parent9ca26444296a88cee90ef32262d169015e595930 (diff)
Prevent ares_strerror() from segfaulting if an invalid error code is passed
in as argument!
-rw-r--r--ares/ares_strerror.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ares/ares_strerror.c b/ares/ares_strerror.c
index 3486ebfbb..ce2edb192 100644
--- a/ares/ares_strerror.c
+++ b/ares/ares_strerror.c
@@ -46,6 +46,8 @@ const char *ares_strerror(int code)
"Illegal hints flags specified"
};
- DEBUGASSERT(code >= 0 && code < (int)(sizeof(errtext) / sizeof(*errtext)));
- return errtext[code];
+ if(code >= 0 && code < (int)(sizeof(errtext) / sizeof(*errtext)))
+ return errtext[code];
+ else
+ return "unknown";
}