From: Moriyoshi Koizumi Date: Fri, 4 Apr 2003 14:18:31 +0000 (+0000) Subject: MFH(r-1.135): fixed memleak in socket_select() X-Git-Tag: php-4.3.2RC2~157 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa00851aa4422a5f46529946977334ef807c47fc;p=php MFH(r-1.135): fixed memleak in socket_select() --- diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 54eefb966f..a63a388451 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -576,10 +576,21 @@ PHP_FUNCTION(socket_select) /* If seconds is not set to null, build the timeval, else we wait indefinitely */ if (sec != NULL) { - convert_to_long_ex(&sec); + zval tmp; + + if (Z_TYPE_P(sec) != IS_LONG) { + tmp = *sec; + zval_copy_ctor(&tmp); + convert_to_long(&tmp); + sec = &tmp; + } tv.tv_sec = Z_LVAL_P(sec); tv.tv_usec = usec; tv_p = &tv; + + if (sec == &tmp) { + zval_dtor(&tmp); + } } retval = select(max_fd+1, &rfds, &wfds, &efds, tv_p);