[PECL-CVS] [pecl-database-ibm_db2] nonempty: Empty strings result in a function sequence error on PASE

[email protected] (Calvin Buckley) Thu, 16 Jul 2026 17:01:59 +0000
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Calvin Buckley (NattyNarwhal)
Date: 2026-07-16T14:01:27-03:00

Commit: https://github.com/php/pecl-database-ibm_db2/commit/9d0f2706fc8027dd6121e3d8cbf3ae0c992d0fc1
Raw diff: https://github.com/php/pecl-database-ibm_db2/commit/9d0f2706fc8027dd6121e3d8cbf3ae0c992d0fc1.diff

Empty strings result in a function sequence error on PASE

It makes no sense to use them.

Changed paths:
  M  ibm_db2.c


Diff:

diff --git a/ibm_db2.c b/ibm_db2.c
index 54dc1bc..5831523 100644
--- a/ibm_db2.c
+++ b/ibm_db2.c
@@ -4038,6 +4038,11 @@ PHP_FUNCTION(db2_exec)
         return;
     }
 
+    if (!stmt_string || stmt_string_len < 1) {
+        zend_argument_value_error(2, "must be a non-empty string");
+        return;
+    }
+
     if (connection) {
         ZEND_FETCH_RESOURCE_2(conn_res, conn_handle*, &connection, connection_id,
             "Connection Resource", le_conn_struct, le_pconn_struct);
@@ -4130,6 +4135,11 @@ PHP_FUNCTION(db2_prepare)
         return;
     }
 
+    if (!stmt_string || stmt_string_len < 1) {
+        zend_argument_value_error(2, "must be a non-empty string");
+        return;
+    }
+
     if (connection) {
         ZEND_FETCH_RESOURCE_2(conn_res, conn_handle*, &connection, connection_id,
             "Connection Resource", le_conn_struct, le_pconn_struct);