From: Nicholas Clark <nick@ccl4.org>
Date: Sun, 15 Feb 2009 21:53:50 +0000 (+0000)
Subject: Ensure that the pointer to S_incpush_use_sep() is never NULL.
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4705144da61264103889bac66eba6d2d56a1da9d;p=p5sagit%2Fp5-mst-13.2.git

Ensure that the pointer to S_incpush_use_sep() is never NULL.
---

diff --git a/embed.fnc b/embed.fnc
index 5c76901..cd3e015 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1475,7 +1475,7 @@ s	|void	|find_beginning	|NN SV* linestr_sv|NN PerlIO *rsfp
 s	|void	|forbid_setid	|const char flag|const bool suidscript
 s	|void	|incpush	|NULLOK const char *const dir|STRLEN len \
 				|U32 flags
-s	|void	|incpush_use_sep|NULLOK const char *p|U32 flags
+s	|void	|incpush_use_sep|NN const char *p|U32 flags
 s	|void	|init_interp
 s	|void	|init_ids
 s	|void	|init_main_stash
diff --git a/perl.c b/perl.c
index a308cf3..9e52c98 100644
--- a/perl.c
+++ b/perl.c
@@ -4110,8 +4110,11 @@ S_init_perllib(pTHX_ U32 old_vers)
 	if (s)
 #endif
 	    incpush_use_sep(s, old_vers ? old_vers : INCPUSH_ADD_SUB_DIRS);
-	else if (!old_vers)
-	    incpush_use_sep(PerlEnv_getenv("PERLLIB"), 0);
+	else if (!old_vers) {
+	    s = PerlEnv_getenv("PERLLIB");
+	    if (s)
+		incpush_use_sep(s, 0);
+	}
 #else /* VMS */
 	/* Treat PERL5?LIB as a possible search list logical name -- the
 	 * "natural" VMS idiom for a Unix path string.  We allow each
@@ -4542,8 +4545,10 @@ S_incpush_use_sep(pTHX_ const char *p, U32 flags)
     /* This logic has been broken out from S_incpush(). It may be possible to
        simplify it.  */
 
+    PERL_ARGS_ASSERT_INCPUSH_USE_SEP;
+
     /* Break at all separators */
-    while (p && *p) {
+    while (*p) {
         const char *s;
 
 	/* skip any consecutive separators */
diff --git a/proto.h b/proto.h
index a2139db..0fb1c33 100644
--- a/proto.h
+++ b/proto.h
@@ -4760,7 +4760,11 @@ STATIC void	S_find_beginning(pTHX_ SV* linestr_sv, PerlIO *rsfp)
 
 STATIC void	S_forbid_setid(pTHX_ const char flag, const bool suidscript);
 STATIC void	S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags);
-STATIC void	S_incpush_use_sep(pTHX_ const char *p, U32 flags);
+STATIC void	S_incpush_use_sep(pTHX_ const char *p, U32 flags)
+			__attribute__nonnull__(pTHX_1);
+#define PERL_ARGS_ASSERT_INCPUSH_USE_SEP	\
+	assert(p)
+
 STATIC void	S_init_interp(pTHX);
 STATIC void	S_init_ids(pTHX);
 STATIC void	S_init_main_stash(pTHX);