summaryrefslogtreecommitdiff
path: root/ext/pdo_dblib/dblib_driver.c
diff options
context:
space:
mode:
authorAdam Baratz <adam.baratz@gmail.com>2016-04-01 11:23:35 -0400
committerAnatol Belski <ab@php.net>2016-04-04 17:33:49 +0200
commit9fcfc18ca9a38ed318f8a7026c0eda27aed79f28 (patch)
treea4fc53a15781eb9089fea444da2219b1dad7e956 /ext/pdo_dblib/dblib_driver.c
parent9a65c69c628462620c2c378658fa6ae11bf1bea7 (diff)
downloadphp-git-9fcfc18ca9a38ed318f8a7026c0eda27aed79f28.tar.gz
Fix #71943: dblib_handle_quoter needs to allocate an extra byte
Diffstat (limited to 'ext/pdo_dblib/dblib_driver.c')
-rw-r--r--ext/pdo_dblib/dblib_driver.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index dcbaf55a3f..9937466561 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -170,7 +170,7 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unqu
*
*/
*quotedlen = (unquotedlen * 2) + 2; /* 2 chars per byte +2 for "0x" prefix */
- q = *quoted = emalloc(*quotedlen);
+ q = *quoted = emalloc(*quotedlen+1); /* Add byte for terminal null */
*q++ = '0';
*q++ = 'x';
@@ -181,7 +181,7 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unqu
} else {
/* Alpha/Numeric Quoting */
*quotedlen += 2; /* +2 for opening, closing quotes */
- q = *quoted = emalloc(*quotedlen);
+ q = *quoted = emalloc(*quotedlen+1); /* Add byte for terminal null */
*q++ = '\'';
for (i=0;i<unquotedlen;i++) {