From: Ilia Alshanetsky Date: Tue, 9 Mar 2004 01:09:35 +0000 (+0000) Subject: Change float operations to safe_emalloc(). X-Git-Tag: php-5.0.0RC1RC1~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7bc8bdec79e6acb3b4588224304eac690f9d0694;p=php Change float operations to safe_emalloc(). Original idea by Sascha (see sess_sqlite.c) --- diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index 9ba406c16b..545a919dc5 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -2612,7 +2612,7 @@ PHP_FUNCTION(sqlite_escape_string) /* binary string */ int enclen; - ret = emalloc( 1 + 5 + stringlen * ((float) 256 / (float) 253) ); + ret = safe_emalloc(1 + stringlen / 254, 257, 3); ret[0] = '\x01'; enclen = php_sqlite_encode_binary(string, stringlen, ret+1); RETVAL_STRINGL(ret, enclen+1, 0); @@ -2842,7 +2842,7 @@ PHP_FUNCTION(sqlite_udf_encode_binary) int enclen; char *ret; - ret = emalloc( 1 + 5 + datalen * ((float) 256 / (float) 253) ); + ret = safe_emalloc(1 + datalen / 254, 257, 3); ret[0] = '\x01'; enclen = php_sqlite_encode_binary(data, datalen, ret+1); RETVAL_STRINGL(ret, enclen+1, 0);