Skip to content

Commit d323ec2

Browse files
committed
Use estrdup
1 parent b85d5f7 commit d323ec2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

ext/mysqli/mysqli_api.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,11 @@ PHP_FUNCTION(mysqli_execute_query)
528528
RETURN_FALSE;
529529
}
530530

531-
/* The bit below, which is copied from mysqli_stmt_prepare, is needed for bad index exceptions */
531+
/* The bit below, which is copied from mysqli_prepare, is needed for bad index exceptions */
532532
/* don't initialize stmt->query with NULL, we ecalloc()-ed the memory */
533533
/* Get performance boost if reporting is switched off */
534534
if (query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
535-
stmt->query = (char *)emalloc(query_len + 1);
536-
memcpy(stmt->query, query, query_len);
537-
stmt->query[query_len] = '\0';
535+
stmt->query = estrdup(query);
538536
}
539537

540538
// bind-in-execute
@@ -1330,9 +1328,7 @@ PHP_FUNCTION(mysqli_prepare)
13301328
/* don't initialize stmt->query with NULL, we ecalloc()-ed the memory */
13311329
/* Get performance boost if reporting is switched off */
13321330
if (stmt->stmt && query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
1333-
stmt->query = (char *)emalloc(query_len + 1);
1334-
memcpy(stmt->query, query, query_len);
1335-
stmt->query[query_len] = '\0';
1331+
stmt->query = estrdup(query);
13361332
}
13371333

13381334
/* don't join to the previous if because it won't work if mysql_stmt_prepare_fails */

0 commit comments

Comments
 (0)