From: Antony Dovgal Date: Mon, 10 Oct 2005 10:44:39 +0000 (+0000) Subject: MF44: fix #33383 (crash when retrieving empty LOBs) X-Git-Tag: php-5.1.0RC2~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c797466259e5c02d9d495206321ae96aa2a5f0d1;p=php MF44: fix #33383 (crash when retrieving empty LOBs) --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 3f71185cd8..0796ac3434 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -1489,7 +1489,12 @@ static int _oci_make_zval(zval *value,oci_statement *statement,oci_out_column *c 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 */ @@ -2248,6 +2253,10 @@ static int oci_loadlob(oci_connection *connection, oci_descriptor *mydescr, char return -1; } + if (readlen == 0) { + return 0; + } + buf = emalloc(readlen + 1); while (readlen > 0) { /* thies loop should not be entered on readlen == 0 */ @@ -2351,6 +2360,10 @@ static int oci_readlob(oci_connection *connection, oci_descriptor *mydescr, char *len = 0; return -1; } + + if (loblen == 0) { + return 0; + } /* check if we're in LOB's borders */ if ((mydescr->lob_current_position + *len) > loblen) { @@ -4015,7 +4028,12 @@ PHP_FUNCTION(oci_lob_load) } 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(); + } } else { RETURN_FALSE; } @@ -4049,7 +4067,12 @@ PHP_FUNCTION(oci_lob_read) loblen = Z_LVAL_PP(len); if (oci_readlob(descr->conn,descr,&buffer,&loblen) == 0) { - RETURN_STRINGL(buffer,loblen,0); + if (loblen > 0) { + RETURN_STRINGL(buffer,loblen,0); + } + else { + RETURN_EMPTY_STRING(); + } } else { RETURN_FALSE; }