This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PerlIO::via: fix compiler warning
authorDavid Mitchell <davem@iabyn.com>
Mon, 18 Nov 2013 14:52:57 +0000 (14:52 +0000)
committerDavid Mitchell <davem@iabyn.com>
Mon, 18 Nov 2013 17:14:22 +0000 (17:14 +0000)
In
    GV *gv = newGVgen(HvNAME_get(s->stash))

HvNAME_get() can return a null value (don't know whether it ever will in
these circumstances), while newGVgen() expects a non-null arg.

So calculate HvNAME_get() first, and bail if it's null.

ext/PerlIO-via/via.pm
ext/PerlIO-via/via.xs

index 601be80..2fa37b1 100644 (file)
@@ -1,5 +1,5 @@
 package PerlIO::via;
 package PerlIO::via;
-our $VERSION = '0.12';
+our $VERSION = '0.13';
 require XSLoader;
 XSLoader::load();
 1;
 require XSLoader;
 XSLoader::load();
 1;
index 56889bf..95ccb3a 100644 (file)
@@ -87,7 +87,12 @@ PerlIOVia_method(pTHX_ PerlIO * f, const char *method, CV ** save, int flags,
        }
        if (*PerlIONext(f)) {
            if (!s->fh) {
        }
        if (*PerlIONext(f)) {
            if (!s->fh) {
-               GV *gv = newGVgen(HvNAME_get(s->stash));
+               GV *gv;
+               char *package = HvNAME_get(s->stash);
+
+                if (!package)
+                    return Nullsv; /* can this ever happen? */
+               gv = newGVgen(package);
                GvIOp(gv) = newIO();
                s->fh = newRV((SV *) gv);
                s->io = GvIOp(gv);
                GvIOp(gv) = newIO();
                s->fh = newRV((SV *) gv);
                s->io = GvIOp(gv);