Change float operations to safe_emalloc().

Original idea by Sascha (see sess_sqlite.c)
This commit is contained in:
Ilia Alshanetsky 2004-03-09 01:09:35 +00:00
parent e375ffddb4
commit 7bc8bdec79

View File

@ -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);