]> granicus.if.org Git - php/commitdiff
use & and check for the right value of result_type
authorAntony Dovgal <tony2001@php.net>
Tue, 10 May 2005 23:12:31 +0000 (23:12 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 10 May 2005 23:12:31 +0000 (23:12 +0000)
ext/pgsql/pgsql.c

index cb16ff936fa7645a64209bd6074cc74ded2136b0..2fa3657b25f04d8d6eb54456e6aafb128f82b3ae 100644 (file)
@@ -4137,6 +4137,11 @@ PHP_FUNCTION(pg_get_notify)
 
        ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
+       if (!(result_type & PGSQL_BOTH)) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid result type");
+               RETURN_FALSE;
+       }
+
        PQconsumeInput(pgsql);
        pgsql_notify = PQnotifies(pgsql);
        if (!pgsql_notify) {
@@ -4144,11 +4149,11 @@ PHP_FUNCTION(pg_get_notify)
                RETURN_FALSE;
        }
        array_init(return_value);
-       if (result_type == PGSQL_NUM || result_type == PGSQL_BOTH) {
+       if (result_type & PGSQL_NUM) {
                add_index_string(return_value, 0, pgsql_notify->relname, 1);
                add_index_long(return_value, 1, pgsql_notify->be_pid);
        }
-       if (result_type == PGSQL_ASSOC || result_type == PGSQL_BOTH) {
+       if (result_type & PGSQL_ASSOC) {
                add_assoc_string(return_value, "message", pgsql_notify->relname, 1);
                add_assoc_long(return_value, "pid", pgsql_notify->be_pid);
        }