From: Thies C. Arntzen Date: Thu, 12 Sep 2002 09:48:03 +0000 (+0000) Subject: @- OCIResult() could return garbage if called on empty result-sets. (thies) X-Git-Tag: MODERN_SYMMETRIC_SESSION_BEHAVIOUR_20021003~356 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b905e40e92dce3ad6eaeae3d09f0f003c5accde3;p=php @- OCIResult() could return garbage if called on empty result-sets. (thies) # fix #19364 --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index ac29732286..54deffb198 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -1244,7 +1244,7 @@ _oci_make_zval(zval *value,oci_statement *statement,oci_out_column *column, char oci_debug("_oci_make_zval: %16s,retlen = %4d,retlen4 = %d,storage_size4 = %4d,indicator %4d, retcode = %4d", column->name,column->retlen,column->retlen4,column->storage_size4,column->indicator,column->retcode); - if (column->indicator == -1) { /* column is NULL */ + if ((! statement->has_data) || (column->indicator == -1)) { /* column is NULL or statment has no current data */ ZVAL_NULL(value); return 0; } @@ -1392,7 +1392,9 @@ static oci_statement *oci_parse(oci_connection *connection, char *query, int len if (query) { statement->last_query = estrdup(query); } + statement->conn = connection; + statement->has_data = 0; statement->id = zend_list_insert(statement,le_stmt); @@ -1769,6 +1771,7 @@ oci_fetch(oci_statement *statement, ub4 nrows, char *func TSRMLS_DC) } statement->error = 0; /* OCI_NO_DATA is NO error for us!!! */ + statement->has_data = 0; return 0; } @@ -1828,12 +1831,16 @@ oci_fetch(oci_statement *statement, ub4 nrows, char *func TSRMLS_DC) _oci_make_zval(column->define->zval,statement,column,"OCIFetch",0 TSRMLS_CC); } + statement->has_data = 1; + return 1; } oci_error(statement->pError, func, statement->error); oci_handle_error(statement->conn, statement->error); + statement->has_data = 0; + return 0; } diff --git a/ext/oci8/php_oci8.h b/ext/oci8/php_oci8.h index 07fdc8e9dc..65d5e1220f 100644 --- a/ext/oci8/php_oci8.h +++ b/ext/oci8/php_oci8.h @@ -119,6 +119,7 @@ typedef struct { HashTable *defines; int ncolumns; int executed; + int has_data; ub2 stmttype; } oci_statement;