diff --git a/ext/I18N-Langinfo/Langinfo.xs b/ext/I18N-Langinfo/Langinfo.xs index 8b1fd5a4ef0c..582b7fa634c6 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