Skip to content

Commit 159f14c

Browse files
realFlowControlarnaud-lb
authored andcommitted
fix memleak due to missing pthread_attr_destroy()-call
Closes GH-14510
1 parent 82e6040 commit 159f14c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010
values during Generator->throw()). (Bob)
1111
. Fixed bug GH-14456 (Attempting to initialize class with private constructor
1212
calls destructor). (Girgias)
13+
. Fixed bug GH-14510 (memleak due to missing pthread_attr_destroy()-call).
14+
(Florian Engelhardt)
1315

1416
- BCMatch:
1517
. Fixed bug (bcpowmod() with mod = -1 returns 1 when it must be 0). (Girgias)

Zend/zend_call_stack.c

+4
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
124124

125125
error = pthread_attr_getstack(&attr, &addr, &max_size);
126126
if (error) {
127+
pthread_attr_destroy(&attr);
127128
return false;
128129
}
129130

@@ -133,6 +134,7 @@ static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
133134
/* In glibc prior to 2.8, addr and size include the guard pages */
134135
error = pthread_attr_getguardsize(&attr, &guard_size);
135136
if (error) {
137+
pthread_attr_destroy(&attr);
136138
return false;
137139
}
138140

@@ -144,6 +146,8 @@ static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
144146
stack->base = (int8_t*)addr + max_size;
145147
stack->max_size = max_size;
146148

149+
pthread_attr_destroy(&attr);
150+
147151
return true;
148152
}
149153
# else /* defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */

0 commit comments

Comments
 (0)