Skip to content

Commit aef715d

Browse files
committed
memset to detect use after free, most likely a race condition.
1 parent d5cd793 commit aef715d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ext-src/swoole_coroutine.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,9 @@ void PHPCoroutine::on_close(void *arg) {
650650
if (ctx->on_close) {
651651
(*ctx->on_close)(ctx);
652652
}
653+
654+
// Mark memory region with special byte pattern to detect use-after-free
655+
memset(ctx, 0xAA, sizeof(PHPContext));
653656
efree(ctx);
654657
}
655658

quick-configure-test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
phpize
3+
./configure --enable-swoole-curl --enable-swoole --enable-openssl --enable-sockets --enable-mysqlnd --enable-debug

0 commit comments

Comments
 (0)