mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix bug #73939 memory allocation in signal handler when HAVE_STRUCT_SIGINFO_T
This commit is contained in:
parent
d11bed5909
commit
bac4c97602
2 changed files with 4 additions and 13 deletions
|
@ -560,11 +560,6 @@ PHP_RSHUTDOWN_FUNCTION(pcntl)
|
||||||
while (PCNTL_G(head)) {
|
while (PCNTL_G(head)) {
|
||||||
sig = PCNTL_G(head);
|
sig = PCNTL_G(head);
|
||||||
PCNTL_G(head) = sig->next;
|
PCNTL_G(head) = sig->next;
|
||||||
#ifdef HAVE_STRUCT_SIGINFO_T
|
|
||||||
if (sig->siginfo) {
|
|
||||||
zend_array_destroy(sig->siginfo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
efree(sig);
|
efree(sig);
|
||||||
}
|
}
|
||||||
while (PCNTL_G(spares)) {
|
while (PCNTL_G(spares)) {
|
||||||
|
@ -1379,11 +1374,7 @@ static void pcntl_signal_handler(int signo)
|
||||||
psig->next = NULL;
|
psig->next = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_STRUCT_SIGINFO_T
|
#ifdef HAVE_STRUCT_SIGINFO_T
|
||||||
zval user_siginfo;
|
psig->siginfo = *siginfo;
|
||||||
array_init(&user_siginfo);
|
|
||||||
pcntl_siginfo_to_zval(signo, siginfo, &user_siginfo);
|
|
||||||
psig->siginfo = zend_array_dup(Z_ARRVAL(user_siginfo));
|
|
||||||
zval_ptr_dtor(&user_siginfo);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* the head check is important, as the tick handler cannot atomically clear both
|
/* the head check is important, as the tick handler cannot atomically clear both
|
||||||
|
@ -1428,14 +1419,14 @@ void pcntl_signal_dispatch()
|
||||||
PCNTL_G(head) = NULL; /* simple stores are atomic */
|
PCNTL_G(head) = NULL; /* simple stores are atomic */
|
||||||
|
|
||||||
/* Allocate */
|
/* Allocate */
|
||||||
|
|
||||||
while (queue) {
|
while (queue) {
|
||||||
if ((handle = zend_hash_index_find(&PCNTL_G(php_signal_table), queue->signo)) != NULL) {
|
if ((handle = zend_hash_index_find(&PCNTL_G(php_signal_table), queue->signo)) != NULL) {
|
||||||
if (Z_TYPE_P(handle) != IS_LONG) {
|
if (Z_TYPE_P(handle) != IS_LONG) {
|
||||||
ZVAL_NULL(&retval);
|
ZVAL_NULL(&retval);
|
||||||
ZVAL_LONG(¶ms[0], queue->signo);
|
ZVAL_LONG(¶ms[0], queue->signo);
|
||||||
#ifdef HAVE_STRUCT_SIGINFO_T
|
#ifdef HAVE_STRUCT_SIGINFO_T
|
||||||
ZVAL_ARR(¶ms[1], queue->siginfo);
|
array_init(¶ms[1]);
|
||||||
|
pcntl_siginfo_to_zval(queue->signo, &queue->siginfo, ¶ms[1]);
|
||||||
#else
|
#else
|
||||||
ZVAL_NULL(¶ms[1]);
|
ZVAL_NULL(¶ms[1]);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -77,7 +77,7 @@ struct php_pcntl_pending_signal {
|
||||||
struct php_pcntl_pending_signal *next;
|
struct php_pcntl_pending_signal *next;
|
||||||
zend_long signo;
|
zend_long signo;
|
||||||
#ifdef HAVE_STRUCT_SIGINFO_T
|
#ifdef HAVE_STRUCT_SIGINFO_T
|
||||||
zend_array *siginfo;
|
siginfo_t siginfo;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue