Skip to content

Commit 4852a2c

Browse files
authored
pdo_dblib: Use stack local array instead of heap allocation (#18801)
1 parent c02f6fb commit 4852a2c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

ext/pdo_dblib/dblib_driver.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,8 @@ zend_string *dblib_handle_last_id(pdo_dbh_t *dbh, const zend_string *name)
233233
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
234234

235235
RETCODE ret;
236-
char *id = NULL;
236+
BYTE id[32];
237237
size_t len;
238-
zend_string *ret_id;
239238

240239
/*
241240
* 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)
267266
return NULL;
268267
}
269268

270-
id = emalloc(32);
271269
len = dbconvert(NULL, (dbcoltype(H->link, 1)) , (dbdata(H->link, 1)) , (dbdatlen(H->link, 1)), SQLCHAR, (BYTE *)id, (DBINT)-1);
272270
dbcancel(H->link);
273271

274-
ret_id = zend_string_init(id, len, 0);
275-
efree(id);
276-
return ret_id;
272+
return zend_string_init((const char *) id, len, 0);
277273
}
278274

279275
static bool dblib_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val)

0 commit comments

Comments
 (0)