From: Jarkko Hietaniemi Date: Thu, 25 Jun 2015 12:41:13 +0000 (-0400) Subject: nl_langinfo code can be negative. X-Git-Tag: v5.23.1~97 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/0c82d9ae6b2b035c99dc9a50d9b317816490d6de nl_langinfo code can be negative. Coverity CID 104814. --- diff --git a/ext/I18N-Langinfo/Langinfo.xs b/ext/I18N-Langinfo/Langinfo.xs index 8b1fd5a..582b7fa 100644 --- a/ext/I18N-Langinfo/Langinfo.xs +++ b/ext/I18N-Langinfo/Langinfo.xs @@ -23,7 +23,12 @@ langinfo(code) PROTOTYPE: _ CODE: #ifdef HAS_NL_LANGINFO - RETVAL = newSVpv(nl_langinfo(code), 0); + if (code < 0) { + SETERRNO(EINVAL, LIB_INVARG); + RETVAL = &PL_sv_undef; + } else { + RETVAL = newSVpv(nl_langinfo(code), 0); + } #else croak("nl_langinfo() not implemented on this architecture"); #endif