Skip to content

Commit db9dcd7

Browse files
committed
Fix leak when wrong args given to last insert ID
1 parent 6041885 commit db9dcd7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ibm_db2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7398,7 +7398,7 @@ PHP_FUNCTION(db2_last_insert_id)
73987398
zval *connection = NULL;
73997399
conn_handle *conn_res;
74007400
int rc;
7401-
char *last_id = emalloc( MAX_IDENTITY_DIGITS );
7401+
char *last_id;
74027402
char *sql;
74037403
SQLHANDLE hstmt;
74047404
#ifdef PASE
@@ -7415,6 +7415,10 @@ PHP_FUNCTION(db2_last_insert_id)
74157415
ZEND_FETCH_RESOURCE_2(conn_res, conn_handle*, &connection, connection_id,
74167416
"Connection Resource", le_conn_struct, le_pconn_struct);
74177417

7418+
last_id = emalloc( MAX_IDENTITY_DIGITS );
7419+
if (!last_id) {
7420+
RETURN_NULL();
7421+
}
74187422
/* get a new statement handle */
74197423
strcpy( last_id, "" );
74207424
rc = SQLAllocHandle(SQL_HANDLE_STMT, conn_res->hdbc, &hstmt);

0 commit comments

Comments
 (0)