summaryrefslogtreecommitdiff
path: root/ext/pdo_mysql/mysql_statement.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-11-05 21:32:31 +0100
committerAnatol Belski <ab@php.net>2015-11-05 21:32:31 +0100
commit7b32b8f4e142dab17d67721f990ec06749db6768 (patch)
tree4ddd3611dcd3d534b4c540b085d2d5445042b111 /ext/pdo_mysql/mysql_statement.c
parent1184f0aca5a4fafc893f131f6012dc44cf5846c4 (diff)
downloadphp-git-7b32b8f4e142dab17d67721f990ec06749db6768.tar.gz
fix pdo_mysql crash with empty bound stream param
rel #70862
Diffstat (limited to 'ext/pdo_mysql/mysql_statement.c')
-rw-r--r--ext/pdo_mysql/mysql_statement.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index f55843072f..7c6d3272fd 100644
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -523,10 +523,11 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
parameter = Z_REFVAL(param->parameter);
}
if (Z_TYPE_P(parameter) == IS_RESOURCE) {
- php_stream *stm;
+ php_stream *stm = NULL;
php_stream_from_zval_no_verify(stm, parameter);
if (stm) {
- ZVAL_STR(parameter, php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0));
+ zend_string *mem = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0);
+ ZVAL_STR(parameter, mem ? mem : STR_EMPTY_ALLOC());
} else {
pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource");
return 0;