Created
June 20, 2014 09:00
-
-
Save dstogov/bc4eefbddc9b61d4685d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main/streams/streams.c b/main/streams/streams.c | |
index 02a313b..f305fe8 100644 | |
--- a/main/streams/streams.c | |
+++ b/main/streams/streams.c | |
@@ -524,20 +524,22 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov | |
/* it leaked: Lets deliberately NOT pefree it so that the memory manager shows it | |
* as leaked; it will log a warning, but lets help it out and display what kind | |
* of stream it was. */ | |
- char *leakinfo; | |
- spprintf(&leakinfo, 0, __FILE__ "(%d) : Stream of type '%s' %p (path:%s) was not closed\n", __LINE__, stream->ops->label, stream, stream->orig_path); | |
+ if (!CG(unclean_shutdown)) { | |
+ char *leakinfo; | |
+ spprintf(&leakinfo, 0, __FILE__ "(%d) : Stream of type '%s' %p (path:%s) was not closed\n", __LINE__, stream->ops->label, stream, stream->orig_path); | |
- if (stream->orig_path) { | |
- pefree(stream->orig_path, stream->is_persistent); | |
- stream->orig_path = NULL; | |
- } | |
+ if (stream->orig_path) { | |
+ pefree(stream->orig_path, stream->is_persistent); | |
+ stream->orig_path = NULL; | |
+ } | |
# if defined(PHP_WIN32) | |
- OutputDebugString(leakinfo); | |
+ OutputDebugString(leakinfo); | |
# else | |
- fprintf(stderr, "%s", leakinfo); | |
+ fprintf(stderr, "%s", leakinfo); | |
# endif | |
- efree(leakinfo); | |
+ efree(leakinfo); | |
+ } | |
} else { | |
if (stream->orig_path) { | |
pefree(stream->orig_path, stream->is_persistent); | |
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c | |
index 9e1521b..b4799d4 100644 | |
--- a/main/streams/xp_socket.c | |
+++ b/main/streams/xp_socket.c | |
@@ -57,7 +57,7 @@ static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count | |
int didwrite; | |
struct timeval *ptimeout; | |
- if (sock->socket == -1) { | |
+ if (!sock || sock->socket == -1) { | |
return 0; | |
} | |
@@ -116,7 +116,7 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data | |
int retval; | |
struct timeval *ptimeout; | |
- if (sock->socket == -1) { | |
+ if (!sock || sock->socket == -1) { | |
return; | |
} | |
@@ -146,7 +146,7 @@ static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS | |
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; | |
int nr_bytes = 0; | |
- if (sock->socket == -1) { | |
+ if (!sock || sock->socket == -1) { | |
return 0; | |
} | |
@@ -179,6 +179,10 @@ static int php_sockop_close(php_stream *stream, int close_handle TSRMLS_DC) | |
int n; | |
#endif | |
+ if (!sock) { | |
+ return 0; | |
+ } | |
+ | |
if (close_handle) { | |
#ifdef PHP_WIN32 | |
@@ -271,6 +275,10 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void | |
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; | |
php_stream_xport_param *xparam; | |
+ if (!sock) { | |
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL; | |
+ } | |
+ | |
switch(option) { | |
case PHP_STREAM_OPTION_CHECK_LIVENESS: | |
{ | |
@@ -413,6 +421,10 @@ static int php_sockop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC) | |
{ | |
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; | |
+ if (!sock) { | |
+ return FAILURE; | |
+ } | |
+ | |
switch(castas) { | |
case PHP_STREAM_AS_STDIO: | |
if (ret) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment