From: Moriyoshi Koizumi Date: Fri, 4 Apr 2003 14:16:59 +0000 (+0000) Subject: Fixed memleak in socket_select X-Git-Tag: RELEASE_0_5~137 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da4cf6f9d864050b2dbaf5631a25f57b777a0bd9;p=php Fixed memleak in socket_select --- diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 5ac4c0a4cb..9b7f0589a9 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);