Skip to content

Commit

Permalink
Fix insertDate method default format not released
Browse files Browse the repository at this point in the history
  • Loading branch information
vidy committed Sep 3, 2024
1 parent 54c3e07 commit 48b892b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kernel/excel.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ PHP_METHOD(vtiful_xls, insertDate)
{
zval *data = NULL, *format_handle = NULL;
zend_long row = 0, column = 0;
zend_string *format = NULL;
zend_string *format = NULL, *default_format = NULL;

ZEND_PARSE_PARAMETERS_START(3, 5)
Z_PARAM_LONG(row)
Expand All @@ -793,7 +793,8 @@ PHP_METHOD(vtiful_xls, insertDate)

// Default datetime format
if (format == NULL || (format != NULL && ZSTR_LEN(format) == 0)) {
format = zend_string_init(ZEND_STRL("yyyy-mm-dd hh:mm:ss"), 0);
default_format = zend_string_init(ZEND_STRL("yyyy-mm-dd hh:mm:ss"), 0);
format = default_format;
}

lxw_datetime datetime = timestamp_to_datetime(data->value.lval);
Expand All @@ -805,8 +806,8 @@ PHP_METHOD(vtiful_xls, insertDate)
}

// Release default format
if (ZEND_NUM_ARGS() == 3) {
zend_string_release(format);
if (default_format != NULL) {
zend_string_release(default_format);
}
}
/* }}} */
Expand Down

0 comments on commit 48b892b

Please sign in to comment.