Skip to content

Commit d154301

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents a4633b1 + a3e6b50 commit d154301

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ PHP NEWS
2626
. Fixed bug #78079 (openssl_encrypt_ccm.phpt fails with OpenSSL 1.1.1c).
2727
(Jakub Zelenka)
2828

29+
- phpdbg:
30+
. Fixed bug #78050 (SegFault phpdbg + opcache on include file twice).
31+
(Nikita)
32+
2933
- Sockets:
3034
. Fixed bug #78038 (Socket_select fails when resource array contains
3135
references). (Nikita)

sapi/phpdbg/phpdbg_list.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -237,29 +237,29 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
237237
zend_op_array *ret;
238238
uint32_t line;
239239
char *bufptr, *endptr;
240-
int size;
240+
size_t len;
241+
242+
/* Copy file contents before calling original compile_file,
243+
* as it may invalidate the file handle. */
244+
if (zend_stream_fixup(file, &bufptr, &len) == FAILURE) {
245+
if (type == ZEND_REQUIRE) {
246+
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file->filename);
247+
zend_bailout();
248+
} else {
249+
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file->filename);
250+
}
251+
}
252+
253+
data.buf = estrndup(bufptr, len);
254+
data.len = len;
241255

242256
ret = PHPDBG_G(compile_file)(file, type);
243257
if (ret == NULL) {
258+
efree(data.buf);
244259
return ret;
245260
}
246261

247-
if (file->type == ZEND_HANDLE_MAPPED) {
248-
data.len = file->handle.stream.mmap.len;
249-
data.buf = emalloc(data.len + 1);
250-
memcpy(data.buf, file->handle.stream.mmap.buf, data.len);
251-
} else {
252-
if (file->type == ZEND_HANDLE_FILENAME) {
253-
zend_stream_open(file->filename, file);
254-
}
255-
256-
size = file->handle.stream.fsizer(file->handle.stream.handle);
257-
data.buf = emalloc(size + 1);
258-
data.len = file->handle.stream.reader(file->handle.stream.handle, data.buf, size);
259-
}
260-
261-
memset(data.buf + data.len, 0, 1);
262-
262+
data.buf[data.len] = '\0';
263263
data.line[0] = 0;
264264
*(dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint32_t) * data.len)) = data;
265265

0 commit comments

Comments
 (0)