pdo_dblib: Use stack local array instead of heap allocation (#18801)

This commit is contained in:
Niels Dossche 2025-06-09 11:13:46 +02:00 committed by GitHub
parent c02f6fb3fe
commit 4852a2c5cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -233,9 +233,8 @@ zend_string *dblib_handle_last_id(pdo_dbh_t *dbh, const zend_string *name)
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
RETCODE ret; RETCODE ret;
char *id = NULL; BYTE id[32];
size_t len; size_t len;
zend_string *ret_id;
/* /*
* Would use scope_identity() but it's not implemented on Sybase * Would use scope_identity() but it's not implemented on Sybase
@ -267,13 +266,10 @@ zend_string *dblib_handle_last_id(pdo_dbh_t *dbh, const zend_string *name)
return NULL; return NULL;
} }
id = emalloc(32);
len = dbconvert(NULL, (dbcoltype(H->link, 1)) , (dbdata(H->link, 1)) , (dbdatlen(H->link, 1)), SQLCHAR, (BYTE *)id, (DBINT)-1); len = dbconvert(NULL, (dbcoltype(H->link, 1)) , (dbdata(H->link, 1)) , (dbdatlen(H->link, 1)), SQLCHAR, (BYTE *)id, (DBINT)-1);
dbcancel(H->link); dbcancel(H->link);
ret_id = zend_string_init(id, len, 0); return zend_string_init((const char *) id, len, 0);
efree(id);
return ret_id;
} }
static bool dblib_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val) static bool dblib_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val)