Skip to content

Commit 792f8fb

Browse files
nikicGirgias
authored andcommitted
Switch name variable to zend_string
1 parent 7aa0036 commit 792f8fb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ext/pdo/pdo_sql_parser.re

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ rewrite:
339339

340340
} else if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
341341
/* rewrite ? to :pdoX */
342-
char *name;
343342
const char *tmpl = stmt->named_rewrite_template ? stmt->named_rewrite_template : ":pdo%d";
344343
int bind_no = 1;
345344

@@ -359,10 +358,10 @@ rewrite:
359358
continue;
360359
}
361360

362-
name = estrndup(plc->pos, plc->len);
361+
zend_string *name = zend_string_init(plc->pos, plc->len, 0);
363362

364363
/* check if bound parameter is already available */
365-
if (!strcmp(name, "?") || (p = zend_hash_str_find_ptr(stmt->bound_param_map, name, plc->len)) == NULL) {
364+
if (zend_string_equals_literal(name, "?") || (p = zend_hash_find_ptr(stmt->bound_param_map, name)) == NULL) {
366365
idxbuf = zend_strpprintf(0, tmpl, bind_no++);
367366
} else {
368367
idxbuf = zend_string_copy(p);
@@ -374,13 +373,13 @@ rewrite:
374373

375374
if (!skip_map && stmt->named_rewrite_template) {
376375
/* create a mapping */
377-
zend_hash_str_update_ptr(stmt->bound_param_map, name, plc->len, zend_string_copy(plc->quoted));
376+
zend_hash_update_ptr(stmt->bound_param_map, name, zend_string_copy(plc->quoted));
378377
}
379378

380379
/* map number to name */
381380
zend_hash_index_update_ptr(stmt->bound_param_map, plc->bindno, zend_string_copy(plc->quoted));
382381

383-
efree(name);
382+
zend_string_release(name);
384383
}
385384

386385
goto rewrite;

0 commit comments

Comments
 (0)