diff --git a/ChangeLog b/ChangeLog index 34a47bb..130afaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -286,6 +286,8 @@ a factor of the size of the compiling workspace (it currently is). 83. Lock out configuring for EBCDIC with non-8-bit libraries. +84. Test for error code <= 0 in regerror(). + Version 10.20 30-June-2015 -------------------------- diff --git a/src/pcre2posix.c b/src/pcre2posix.c index 134a0c1..2792c17 100644 --- a/src/pcre2posix.c +++ b/src/pcre2posix.c @@ -147,7 +147,7 @@ regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) int used; const char *message; -message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))? +message = (errcode <= 0 || errcode >= (int)(sizeof(pstring)/sizeof(char *)))? "unknown error code" : pstring[errcode]; if (preg != NULL && (int)preg->re_erroffset != -1)