From: Antony Dovgal Date: Mon, 10 Oct 2005 10:41:24 +0000 (+0000) Subject: fix #33383 (crash when retrieving empty LOBs) X-Git-Tag: php-4.4.1~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e8f1c0949752ca2b7cef2ef10f747e678a58fd4;p=php fix #33383 (crash when retrieving empty LOBs) --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 201ac7874c..a9245697a0 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -1285,7 +1285,12 @@ _oci_make_zval(zval *value,oci_statement *statement,oci_out_column *column, char if (oci_loadlob(statement->conn,descr,&buffer,&loblen)) { ZVAL_FALSE(value); } else { - ZVAL_STRINGL(value,buffer,loblen,0); + if (loblen > 0) { + ZVAL_STRINGL(value,buffer,loblen,0); + } + else { + ZVAL_EMPTY_STRING(value); + } } } else { /* return the locator */ @@ -1912,6 +1917,10 @@ oci_loadlob(oci_connection *connection, oci_descriptor *mydescr, char **buffer,u return -1; } + if (readlen == 0) { + return 0; + } + buf = emalloc(readlen + 1); while (readlen > 0) { /* thies loop should not be entered on readlen == 0 */ @@ -2527,7 +2536,7 @@ static oci_server *_oci_open_server(char *dbname,int persistent) /* breakthru to open */ } } - + server = calloc(1,sizeof(oci_server)); server->persistent = persistent; @@ -3286,7 +3295,12 @@ PHP_FUNCTION(ociloadlob) } if (!oci_loadlob(descr->conn,descr,&buffer,&loblen)) { - RETURN_STRINGL(buffer,loblen,0); + if (loblen > 0) { + RETURN_STRINGL(buffer,loblen,0); + } + else { + RETURN_EMPTY_STRING(); + } } }