Author: turnstep
Date: Mon Apr 20 09:42:07 2009
New Revision: 12711

Modified:
   DBD-Pg/trunk/Changes
   DBD-Pg/trunk/dbdimp.c

Log:
Fix leak in pg_warn, per bug 45163. Thanks to [email protected] for the 
patch.


Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes        (original)
+++ DBD-Pg/trunk/Changes        Mon Apr 20 09:42:07 2009
@@ -1,5 +1,9 @@
 ('GSM' is Greg Sabino Mullane, [email protected])
 
+2.13.1
+
+  - Fix leak in pg_warn (CPAN bug #45163) [[email protected]]
+
 2.13.0 Released April 13, 2009
 
   - Ensure we always set sqlstate inside of pg_st_prepare_statement

Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c       (original)
+++ DBD-Pg/trunk/dbdimp.c       Mon Apr 20 09:42:07 2009
@@ -277,6 +277,9 @@
 static void pg_warn (void * arg, const char * message)
 {
        dTHX;
+       SV *tmp;
+
+       tmp = sv_2mortal(newRV((SV *)arg));
 
        /* This fun little bit is to prevent a core dump when the following 
occurs:
           client_min_messages is set to DEBUG3 or greater, and we exit without 
a disconnect.
@@ -289,11 +292,11 @@
           like DBIc_WARN. There may be a better way of handling all this, and 
we may want to 
           default to always warn() - input welcome.
        */
-       if (!SvROK(SvMAGIC(SvRV(newRV((SV*)arg)))->mg_obj)) {
+       if (!SvROK(SvMAGIC(SvRV(tmp))->mg_obj)) {
                return;
        }
        else {
-               D_imp_dbh( sv_2mortal(newRV((SV*)arg)) );
+               D_imp_dbh(tmp);
 
                if (TSTART) TRC(DBILOGFP, "%sBegin pg_warn (message: %s 
DBIc_WARN: %d PrintWarn: %d)\n",
                                                THEADER,

Reply via email to