[perl #128740] Check for null in pp_ghostent et al.
authorFather Chrysostomos <[email protected]>
Mon, 1 Aug 2016 02:21:02 +0000 (19:21 -0700)
committerFather Chrysostomos <[email protected]>
Mon, 1 Aug 2016 15:23:00 +0000 (08:23 -0700)
Specifically in the S_space_join_names_mortal static function that
several pp functions call.  On some platforms (such as Gentoo Linux
with torsocks), hent->h_aliases (where hent is a struct hostent *) may
be null after a gethostent call.

embed.fnc
pp_sys.c
proto.h

index c0b7a3e..2021b3e 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -2132,7 +2132,7 @@ s |OP*    |doform         |NN CV *cv|NN GV *gv|NULLOK OP *retop
 #  if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
 sR     |int    |dooneliner     |NN const char *cmd|NN const char *filename
 #  endif
-s      |SV *   |space_join_names_mortal|NN char *const *array
+s      |SV *   |space_join_names_mortal|NULLOK char *const *array
 #endif
 p      |OP *   |tied_method|NN SV *methname|NN SV **sp \
                                |NN SV *const sv|NN const MAGIC *const mg \
index 3bf2673..d16a0e5 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4934,9 +4934,7 @@ S_space_join_names_mortal(pTHX_ char *const *array)
 {
     SV *target;
 
-    PERL_ARGS_ASSERT_SPACE_JOIN_NAMES_MORTAL;
-
-    if (*array) {
+    if (array && *array) {
        target = newSVpvs_flags("", SVs_TEMP);
        while (1) {
            sv_catpv(target, *array);
diff --git a/proto.h b/proto.h
index a06b6d0..da11ced 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -4859,8 +4859,6 @@ STATIC OP*        S_doform(pTHX_ CV *cv, GV *gv, OP *retop);
 #define PERL_ARGS_ASSERT_DOFORM        \
        assert(cv); assert(gv)
 STATIC SV *    S_space_join_names_mortal(pTHX_ char *const *array);
-#define PERL_ARGS_ASSERT_SPACE_JOIN_NAMES_MORTAL       \
-       assert(array)
 #endif
 #if defined(PERL_IN_REGCOMP_C)
 STATIC SV*     S__make_exactf_invlist(pTHX_ RExC_state_t *pRExC_state, regnode *node)