From: Gustavo André dos Santos Lopes Date: Sun, 1 May 2011 03:57:01 +0000 (+0000) Subject: - Fixed bug #54623 (Segfault when when writing to a persistent socket after X-Git-Tag: php-5.4.0alpha1~191^2~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93f65cdeac1e20e5ad789609894c116261e7f273;p=php - Fixed bug #54623 (Segfault when when writing to a persistent socket after closing a copy of the socket). --- diff --git a/ext/standard/tests/streams/bug54623.phpt b/ext/standard/tests/streams/bug54623.phpt new file mode 100644 index 0000000000..cd83854f43 --- /dev/null +++ b/ext/standard/tests/streams/bug54623.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #54623: Segfault when when writing to a persistent socket after closing a copy of the socket +--FILE-- +ptr == le->ptr) { + zend_hash_get_current_key_ex(&EG(regular_list), NULL, NULL, + &index, 0, &pos); + break; + } + zend_hash_move_forward_ex(&EG(regular_list), &pos); + } + *stream = (php_stream*)le->ptr; - le->refcount++; - (*stream)->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, *stream, le_pstream); + if (index == -1) { /* not found in regular list */ + le->refcount++; + (*stream)->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, *stream, le_pstream); + } else { + regentry->refcount++; + (*stream)->rsrc_id = index; + } } return PHP_STREAM_PERSISTENT_SUCCESS; } @@ -480,7 +503,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov stream->orig_path = NULL; } -# if defined(PHP_WIN32) +# if defined(PHP_WIN32_) OutputDebugString(leakinfo); # else fprintf(stderr, "%s", leakinfo);