diff options
-rw-r--r-- | ext/pdo_firebird/firebird_statement.c | 2 | ||||
-rw-r--r-- | ext/pdo_firebird/tests/bug_76488.phpt | 32 | ||||
-rw-r--r-- | win32/wsyslog.c | 8 |
3 files changed, 38 insertions, 4 deletions
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c index bfe2dd717d..46dc10760a 100644 --- a/ext/pdo_firebird/firebird_statement.c +++ b/ext/pdo_firebird/firebird_statement.c @@ -294,7 +294,7 @@ static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ * unsigned short seg_len; ISC_STATUS stat; - *ptr = S->fetch_buf[colno] = erealloc(*ptr, *len+1); + *ptr = S->fetch_buf[colno] = erealloc(S->fetch_buf[colno], *len+1); for (cur_len = stat = 0; (!stat || stat == isc_segment) && cur_len < *len; cur_len += seg_len) { diff --git a/ext/pdo_firebird/tests/bug_76488.phpt b/ext/pdo_firebird/tests/bug_76488.phpt new file mode 100644 index 0000000000..dba6734c28 --- /dev/null +++ b/ext/pdo_firebird/tests/bug_76488.phpt @@ -0,0 +1,32 @@ +--TEST-- +PDO_Firebird: Bug #76488 Memory leak when fetching a BLOB field +--SKIPIF-- +<?php if (!extension_loaded('interbase') || !extension_loaded('pdo_firebird')) die('skip'); ?> +--FILE-- +<?php +require 'testdb.inc'; +$dbh = new PDO('firebird:dbname='.$test_base, $user, $password) or die; + +$sql = ' +with recursive r(n) as ( + select 1 from rdb$database + union all + select n+1 from r where n < 1000 +) +select n, + cast(lpad(\'A\', 8000, \'A\') as BLOB sub_type TEXT) as SRC +from r +'; + + for ($i = 0; $i < 10; $i++) { + $sth = $dbh->prepare($sql); + $sth->execute(); + $rows = $sth->fetchAll(); + unset($rows); + unset($sth); + } + unset($dbh); + echo "OK"; +?> +--EXPECT-- +OK
\ No newline at end of file diff --git a/win32/wsyslog.c b/win32/wsyslog.c index 6b0f03e8ea..73f9969a78 100644 --- a/win32/wsyslog.c +++ b/win32/wsyslog.c @@ -66,7 +66,7 @@ void closelog(void) PW32G(log_source) = INVALID_HANDLE_VALUE; } if (PW32G(log_header)) { - efree(PW32G(log_header)); + free(PW32G(log_header)); PW32G(log_header) = NULL; } } @@ -112,7 +112,6 @@ void syslog(int priority, const char *message, ...) efree(tmp); } - /* Emulator for BSD openlog() routine * Accepts: identity * options @@ -121,11 +120,14 @@ void syslog(int priority, const char *message, ...) void openlog(const char *ident, int logopt, int facility) { + size_t header_len; closelog(); PW32G(log_source) = RegisterEventSource(NULL, "PHP-" PHP_VERSION); - spprintf(&PW32G(log_header), 0, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid()); + header_len = strlen(ident) + 2 + 11; + PW32G(log_header) = malloc(header_len*sizeof(char)); + sprintf_s(PW32G(log_header), header_len, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid()); } /* |