From 250e7c40208cbe90dc3ab0b2bdf7adca7659b1c3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Oct 2007 22:51:38 +0000 Subject: [PATCH] Prevent ares_strerror() from segfaulting if an invalid error code is passed in as argument! --- ares_strerror.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ares_strerror.c b/ares_strerror.c index 3486ebfb..ce2edb19 100644 --- a/ares_strerror.c +++ b/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"; }