summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArd Biesheuvel <abies@php.net>2004-05-30 17:51:19 +0000
committerArd Biesheuvel <abies@php.net>2004-05-30 17:51:19 +0000
commit18fa78842d017fc2fa9e0dd0097f76ad3be409b5 (patch)
tree349251e0a2fc4d61f1b7a3e29f09ac0625867737
parente54165e4062804a1aa8c7c3cc4b87021d181d4d5 (diff)
downloadphp-git-18fa78842d017fc2fa9e0dd0097f76ad3be409b5.tar.gz
Fix unregistered bug (segfault on uninitialised pointer)
Return string("0 ") from ibase_query() if query succeeded but did not affect any rows
-rw-r--r--ext/interbase/ibase_query.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c
index 0caf2b43a6..911417210b 100644
--- a/ext/interbase/ibase_query.c
+++ b/ext/interbase/ibase_query.c
@@ -307,6 +307,8 @@ static int _php_ibase_alloc_query(ibase_query *ib_query, ibase_db_link *link, /*
ib_query->dialect = dialect;
ib_query->query = estrdup(query);
ib_query->trans_res_id = trans_res_id;
+ ib_query->out_sqlda = NULL;
+ ib_query->in_sqlda = NULL;
if (isc_dsql_allocate_statement(IB_STATUS, &link->handle, &ib_query->stmt)) {
_php_ibase_error(TSRMLS_C);
@@ -989,10 +991,16 @@ static int _php_ibase_exec(INTERNAL_FUNCTION_PARAMETERS, ibase_result **ib_resul
i += len+3;
}
}
- if (affected_rows > 0) {
- ib_query->trans->affected_rows = affected_rows;
- RETVAL_LONG(affected_rows);
- break;
+
+ ib_query->trans->affected_rows = affected_rows;
+
+ if (!ib_query->out_sqlda) { /* no result set is being returned */
+ if (affected_rows) {
+ RETVAL_LONG(affected_rows);
+ } else {
+ /* this return value evaluates to bool(true) and to int(0) */
+ RETVAL_STRINGL("0 ",2,1);
+ }
}
default: