Skip to content

Commit e175d97

Browse files
committed
When freeing memory, set the pointer to NULL.
1 parent 73b25e8 commit e175d97

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ext/pdo_firebird/firebird_driver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,15 @@ static void firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */
493493

494494
if (H->date_format) {
495495
efree(H->date_format);
496+
H->date_format = NULL;
496497
}
497498
if (H->time_format) {
498499
efree(H->time_format);
500+
H->time_format = NULL;
499501
}
500502
if (H->timestamp_format) {
501503
efree(H->timestamp_format);
504+
H->timestamp_format = NULL;
502505
}
503506

504507
pefree(H, dbh->is_persistent);
@@ -882,6 +885,7 @@ static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *
882885
}
883886
if (H->date_format) {
884887
efree(H->date_format);
888+
H->date_format = NULL;
885889
}
886890
spprintf(&H->date_format, 0, "%s", ZSTR_VAL(str));
887891
zend_string_release_ex(str, 0);
@@ -896,6 +900,7 @@ static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *
896900
}
897901
if (H->time_format) {
898902
efree(H->time_format);
903+
H->time_format = NULL;
899904
}
900905
spprintf(&H->time_format, 0, "%s", ZSTR_VAL(str));
901906
zend_string_release_ex(str, 0);
@@ -910,6 +915,7 @@ static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *
910915
}
911916
if (H->timestamp_format) {
912917
efree(H->timestamp_format);
918+
H->timestamp_format = NULL;
913919
}
914920
spprintf(&H->timestamp_format, 0, "%s", ZSTR_VAL(str));
915921
zend_string_release_ex(str, 0);

0 commit comments

Comments
 (0)