]> granicus.if.org Git - php/commitdiff
Fixed memleak in socket_select
authorMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 4 Apr 2003 14:16:59 +0000 (14:16 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 4 Apr 2003 14:16:59 +0000 (14:16 +0000)
ext/sockets/sockets.c

index 5ac4c0a4cb9616575446cfb77ad2724fbc321f5f..9b7f0589a9c4888f07d58d43f6179c3f44b8df49 100644 (file)
@@ -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);