diff options
author | Ard Biesheuvel <abies@php.net> | 2004-05-12 13:14:55 +0000 |
---|---|---|
committer | Ard Biesheuvel <abies@php.net> | 2004-05-12 13:14:55 +0000 |
commit | b4939dfa9adfc3d1561735cd3f95206844aca680 (patch) | |
tree | bef13bd96d8e553da0c345b8d86b4072399a1bdc /ext/interbase | |
parent | ecfd014357e4ba77a48d1c4ed81f03fcc2eb7600 (diff) | |
download | php-git-b4939dfa9adfc3d1561735cd3f95206844aca680.tar.gz |
Made ibase_timefmt() check its args more thoroughly and nuked a pointless malloc()
Diffstat (limited to 'ext/interbase')
-rw-r--r-- | ext/interbase/interbase.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c index 6c5801900e..87a23ee76d 100644 --- a/ext/interbase/interbase.c +++ b/ext/interbase/interbase.c @@ -1136,34 +1136,18 @@ PHP_FUNCTION(ibase_rollback_ret) #endif /* }}} */ -#if HAVE_STRFTIME /* {{{ proto bool ibase_timefmt(string format [, int type ]) Sets the format of timestamp, date and time columns returned from queries */ PHP_FUNCTION(ibase_timefmt) { - zval ***args; - char *fmt = NULL; - int type = PHP_IBASE_TIMESTAMP; - - if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2) { - WRONG_PARAM_COUNT; - } + char *fmt; + int fmt_len; + long type = PHP_IBASE_TIMESTAMP; - args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0); - if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) { - efree(args); + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &fmt, &fmt_len, &type)) { RETURN_FALSE; } - switch (ZEND_NUM_ARGS()) { - case 2: - convert_to_long_ex(args[1]); - type = Z_LVAL_PP(args[1]); - case 1: - convert_to_string_ex(args[0]); - fmt = Z_STRVAL_PP(args[0]); - } - switch (type) { case PHP_IBASE_TIMESTAMP: if (IBG(timestampformat)) { @@ -1183,13 +1167,13 @@ PHP_FUNCTION(ibase_timefmt) } IBG(timeformat) = DL_STRDUP(fmt); break; + default: + RETURN_FALSE; } - efree(args); RETURN_TRUE; } /* }}} */ -#endif /* {{{ proto int ibase_gen_id(string generator [, int increment [, resource link_identifier ]]) Increments the named generator and returns its new value */ |