[svn:dbd-oracle] r15357 - dbd-oracle/trunk
[email protected] Mon, 6 Aug 2012 06:53:09 -0700 (PDT)
| Newsgroups | perl.dbd.oracle.changes |
|---|---|
| Message-ID | <[email protected]> |
Author: mjevans
Date: Mon Aug 6 06:53:08 2012
New Revision: 15357
Modified:
dbd-oracle/trunk/Changes
dbd-oracle/trunk/dbdimp.c
dbd-oracle/trunk/oci8.c
Log:
Fix memory leak in TAF support - the TAF function is leaked
If the taf_function is passed as a scalar which has gone out of scope
TAF support will probably break badly
why oh why wasn't taf_function a code ref instead of a string :-(
Modified: dbd-oracle/trunk/Changes
==============================================================================
--- dbd-oracle/trunk/Changes (original)
+++ dbd-oracle/trunk/Changes Mon Aug 6 06:53:08 2012
@@ -9,6 +9,12 @@
- fix finding client in situation where client and server both
installed but different architectures (patch by H.Merijn Brand)
+ - fix memeory leak in TAF handling - the TAF function was leaked
+ (Martin J. Evans)
+
+ - fix issue with taf_function being set to a scalar which goes
+ out of scope before the callback is made (Martin J. Evans)
+
[MISCELLANEOUS]
- hide dr, db and st packages from PAUSE
Modified: dbd-oracle/trunk/dbdimp.c
==============================================================================
--- dbd-oracle/trunk/dbdimp.c (original)
+++ dbd-oracle/trunk/dbdimp.c Mon Aug 6 06:53:08 2012
@@ -33,7 +33,7 @@
DBISTATE_DECLARE;
-int ora_fetchtest; /* intrnal test only, not thread safe */
+int ora_fetchtest; /* internal test only, not thread safe */
int is_extproc = 0; /* not ProC but ExtProc.pm */
int dbd_verbose = 0; /* DBD only debugging*/
int oci_warn = 0; /* show oci warnings */
@@ -489,10 +489,13 @@
DBD_ATTRIB_GET_IV( attr, "ora_taf_sleep", 13, svp, imp_dbh->taf_sleep);
if ((svp=DBD_ATTRIB_GET_SVP(attr, "ora_taf_function", 16)) && SvOK(*svp)) {
STRLEN svp_len;
+ char *fn;
+
if (!SvPOK(*svp))
croak("ora_taf_function is not a string");
- imp_dbh->taf_function = (char *) SvPV (*svp, svp_len );
-
+ fn = SvPV(*svp, svp_len);
+ imp_dbh->taf_function = (char *)safemalloc(svp_len + 1);
+ strcpy(imp_dbh->taf_function, fn);
}
if (DBIc_DBISTATE(imp_dbh)->debug || dbd_verbose >= 3)
PerlIO_printf(
@@ -1121,6 +1124,11 @@
(ub4) OCI_ATTR_FOCBK, imp_dbh->errhp, status);
}
+ if (imp_dbh->taf_function) {
+ Safefree(imp_dbh->taf_function);
+ imp_dbh->taf_function = NULL;
+ }
+
#ifdef ORA_OCI_112
if (imp_dbh->using_drcp) {
OCIHandleFree_log_stat(imp_dbh, imp_dbh->authp, OCI_HTYPE_SESSION,status);
Modified: dbd-oracle/trunk/oci8.c
==============================================================================
--- dbd-oracle/trunk/oci8.c (original)
+++ dbd-oracle/trunk/oci8.c Mon Aug 6 06:53:08 2012
@@ -1361,19 +1361,16 @@
dTHX;
OCIFocbkStruct tafailover;
sword status;
- taf_callback_t *cb = NULL;
-/*allocate space for the callback */
- Newz(1, cb, 1, taf_callback_t);
- cb->function= (char*)safemalloc(strlen(imp_dbh->taf_function) + 1);
- cb->sleep = imp_dbh->taf_sleep;
- strcpy((char *)cb->function,imp_dbh->taf_function);
+
+ imp_dbh->taf_ctx.function = imp_dbh->taf_function;
+ imp_dbh->taf_ctx.sleep = imp_dbh->taf_sleep;
if (dbd_verbose >= 5 ) {
PerlIO_printf(DBIc_LOGPIO(imp_dbh), " In reg_taf_callback\n");
}
/* set the context up as a pointer to the taf callback struct*/
- tafailover.fo_ctx = cb;
+ tafailover.fo_ctx = &imp_dbh->taf_ctx;
tafailover.callback_function = &taf_cbk;
/* register the callback */