This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
nl_langinfo code can be negative.
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 25 Jun 2015 12:41:13 +0000 (08:41 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 27 Jun 2015 03:09:44 +0000 (23:09 -0400)
Coverity CID 104814.

ext/I18N-Langinfo/Langinfo.xs

index 8b1fd5a..582b7fa 100644 (file)
@@ -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