Prevent ares_strerror() from segfaulting if an invalid error code is passed

in as argument!
This commit is contained in:
Daniel Stenberg 2007-10-01 22:51:38 +00:00
parent 9ca2644429
commit dbd4abf0ff

View File

@ -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";
}