Skip to content

Commit

Permalink
Merge pull request #523 from videni/hotfix/fix-insert-date-unreleased…
Browse files Browse the repository at this point in the history
…-default-format

Fix insertDate method default format not released
  • Loading branch information
viest authored Sep 4, 2024
2 parents da9b4f0 + 2aec4de commit 5742554
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 @@ -773,7 +773,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 @@ -798,7 +798,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 @@ -810,8 +811,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 5742554

Please sign in to comment.