This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Potential (?) memory leak in Storable.xs (Coverity)
authorbah@longitude.com <bah@longitude.com>
Sat, 15 Apr 2006 13:54:10 +0000 (09:54 -0400)
committerNicholas Clark <nick@ccl4.org>
Sat, 15 Apr 2006 23:41:23 +0000 (23:41 +0000)
Message-ID: <1561.38.96.138.153.1145123650.squirrel@mail.longitude.com>
Date: Sat, 15 Apr 2006 13:54:10 -0400 (EDT)

p4raw-id: //depot/perl@27828

ext/Storable/Storable.xs

index a8beda1..b77853c 100644 (file)
@@ -3989,8 +3989,11 @@ static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, const char *cname)
 
        TRACEME(("new class name \"%s\" will bear ID = %d", classname, cxt->classnum));
 
-       if (!av_store(cxt->aclass, cxt->classnum++, newSVpvn(classname, len)))
+       if (!av_store(cxt->aclass, cxt->classnum++, newSVpvn(classname, len))) {
+               if (classname != buf)
+                       Safefree(classname);
                return (SV *) 0;
+       }
 
        /*
         * Retrieve object and bless it.
@@ -4168,8 +4171,11 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, const char *cname)
                 * Record new classname.
                 */
 
-               if (!av_store(cxt->aclass, cxt->classnum++, newSVpvn(classname, len)))
+               if (!av_store(cxt->aclass, cxt->classnum++, newSVpvn(classname, len))) {
+                       if (classname != buf)
+                               Safefree(classname);
                        return (SV *) 0;
+               }
        }
 
        TRACEME(("class name: %s", classname));