-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reset EG(trampoline).op_array.last_var that FFI may modify
Closes GH-10916
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--TEST-- | ||
Memory corruption when mixing __callStatic() and FFI | ||
--EXTENSIONS-- | ||
ffi | ||
--SKIPIF-- | ||
<?php | ||
try { | ||
$libc = FFI::cdef("int printf(const char *format, ...);", "libc.so.6"); | ||
} catch (Throwable $_) { | ||
die('skip libc.so.6 not available'); | ||
} | ||
?> | ||
--INI-- | ||
ffi.enable=1 | ||
--FILE-- | ||
<?php | ||
class Test | ||
{ | ||
public static function __callStatic($name, $args) | ||
{ | ||
echo "$name called\n"; | ||
} | ||
} | ||
|
||
$header = ' | ||
typedef struct _IO_FILE FILE; | ||
extern FILE *stdout; | ||
int fprintf(FILE *, const char *, ...); | ||
int fflush(FILE *); | ||
'; | ||
$ffi = FFI::cdef($header, 'libc.so.6'); | ||
|
||
Test::foo(); | ||
Test::bar(); | ||
$ffi->fprintf($ffi->stdout, "FFI\n"); | ||
$ffi->fflush($ffi->stdout); | ||
Test::baz(); | ||
?> | ||
--EXPECT-- | ||
foo called | ||
bar called | ||
FFI | ||
baz called |