@@ -76,7 +76,7 @@ struct placeholder {
76
76
};
77
77
78
78
static void free_param_name (zval *el) {
79
- efree (Z_PTR_P (el));
79
+ zend_string_release (Z_PTR_P (el));
80
80
}
81
81
82
82
PDO_API int pdo_parse_params (pdo_stmt_t *stmt, zend_string *inquery, zend_string **outquery)
@@ -352,7 +352,7 @@ rewrite:
352
352
353
353
for (plc = placeholders; plc; plc = plc->next ) {
354
354
int skip_map = 0 ;
355
- char *p;
355
+ zend_string *p;
356
356
zend_string *idxbuf;
357
357
358
358
if (plc->bindno == PDO_PARSER_BINDNO_ESCAPED_CHAR) {
@@ -365,7 +365,7 @@ rewrite:
365
365
if (!strcmp (name, " ?" ) || (p = zend_hash_str_find_ptr (stmt->bound_param_map , name, plc->len )) == NULL ) {
366
366
idxbuf = zend_strpprintf (0 , tmpl, bind_no++);
367
367
} else {
368
- idxbuf = zend_string_init (p, strlen (p), 0 );
368
+ idxbuf = zend_string_copy (p );
369
369
skip_map = 1 ;
370
370
}
371
371
@@ -374,11 +374,11 @@ rewrite:
374
374
375
375
if (!skip_map && stmt->named_rewrite_template ) {
376
376
/* create a mapping */
377
- zend_hash_str_update_mem (stmt->bound_param_map , name, plc->len , ZSTR_VAL (plc->quoted ), ZSTR_LEN (plc-> quoted ) + 1 );
377
+ zend_hash_str_update_ptr (stmt->bound_param_map , name, plc->len , zend_string_copy (plc->quoted ));
378
378
}
379
379
380
380
/* map number to name */
381
- zend_hash_index_update_mem (stmt->bound_param_map , plc->bindno , ZSTR_VAL (plc->quoted ), ZSTR_LEN (plc-> quoted ) + 1 );
381
+ zend_hash_index_update_ptr (stmt->bound_param_map , plc->bindno , zend_string_copy (plc->quoted ));
382
382
383
383
efree (name);
384
384
}
@@ -396,10 +396,8 @@ rewrite:
396
396
}
397
397
398
398
for (plc = placeholders; plc; plc = plc->next ) {
399
- char *name;
400
- name = estrndup (plc->pos , plc->len );
401
- zend_hash_index_update_mem (stmt->bound_param_map , plc->bindno , name, plc->len + 1 );
402
- efree (name);
399
+ zend_string *name = zend_string_init (plc->pos , plc->len , 0 );
400
+ zend_hash_index_update_ptr (stmt->bound_param_map , plc->bindno , name);
403
401
plc->quoted = ZSTR_CHAR (' ?' );
404
402
newbuffer_len -= plc->len - 1 ;
405
403
}
0 commit comments