Ruslan Osmanov avatar Ruslan Osmanov committed 8e56a15

Fix: bug #64652 where Event::__construct returned valid object, however, with
uninitialized internal struct which caused segmentation faults in further method calls

Comments (0)

Files changed (3)

  * Creates new event */
 PHP_METHOD(Event, __construct)
 {
+	zval                   *zself = getThis();
 	zval                   *zbase;
 	php_event_base_t       *b;
 	zval                  **ppzfd;
 	evutil_socket_t         fd;
 	long                    what;
-	zend_fcall_info         fci     = empty_fcall_info;
-	zend_fcall_info_cache   fcc     = empty_fcall_info_cache;
-	zval                   *arg     = NULL;
+	zend_fcall_info         fci   = empty_fcall_info;
+	zend_fcall_info_cache   fcc   = empty_fcall_info_cache;
+	zval                   *arg   = NULL;
 	php_event_t            *e;
 	struct event           *event;
 
 
 	if (what & ~(EV_TIMEOUT | EV_READ | EV_WRITE | EV_SIGNAL | EV_PERSIST | EV_ET)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid mask");
-		RETURN_FALSE;
+		ZVAL_NULL(zself);
+		return;
 	}
 
 	if (what & EV_SIGNAL) {
 		fd = zval_to_signum(ppzfd);
 		if (fd == -1) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid signal passed");
-			RETURN_FALSE;
+			ZVAL_NULL(zself);
+			return;
 		}
 	} else if (what & EV_TIMEOUT) {
 		fd = -1;
 	} else {
 		fd = (evutil_socket_t) php_event_zval_to_fd(ppzfd TSRMLS_CC);
 		if (fd < 0) {
-			RETURN_FALSE;
+			ZVAL_NULL(zself);
+			return;
 		}
 	}
 
 
 	/* TODO: check if a signum bound to different event bases */
 
-	e = (php_event_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+	e = (php_event_t *) zend_object_store_get_object(zself TSRMLS_CC);
 
 	event = event_new(b->base, fd, what, event_cb, (void *) e);
 	if (!event) {
 		php_error_docref(NULL TSRMLS_CC, E_ERROR, "event_new failed");
-		RETURN_FALSE;
+		ZVAL_NULL(zself);
+		return;
 	}
 
 	e->event = event;
     <email>osmanov@php.net</email>
     <active>yes</active>
   </lead>
-  <date>2013-04-02</date>
+  <date>2013-04-17</date>
   <!--{{{ Current version -->
   <version>
-    <release>1.6.0</release>
+    <release>1.6.1</release>
     <api>1.6.0</api>
   </version>
   <stability>
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
   <notes><![CDATA[
-  Fix: bug #64551 with build failed on Mac OS X
-  Fix: address argument of the listener accept callback contained garbage in case of a client connected via UNIX domain socket
-  Add: EventBuffer::write, EventUtil::setSocketOption methods and some constants
-  Refact: automatically set the upper bound of EventBuffer::search to the buffer length, if it is greater then the length
-  Fix: make the code compatible with PHP 5.5.0 .. 5.6.0-dev
-  Fix: build error with zts PHP setup
-  Fix: build error with libevent_extra disabled
-  Add: EventListener fd readonly property for numeric file descriptor of the socket associated with the listener
-  Add: EventBuffer::substr method
-
-  INCOMPATIBLE CHANGES!
-  Renamed EventBuffer::remove to EventBuffer::read, EventBuffer::read now takes only max_bytes argument and returns string.
-  Renamed EventBuffer::removeBuffer to EventBuffer::appendFrom
-  EventBuffer::read now takes single argument 'size' and returns the string read
+  Fix: bug #64652 where Event::__construct returned valid object, however, with
+  uninitialized internal struct which caused segmentation faults in further
+  method calls
   ]]></notes>
   <!--}}}-->
   <!--{{{ Contents -->
   </extsrcrelease>
   <!--{{{ changelog-->
   <changelog>
+    <!--{{{ 1.6.1 -->
+    <release>
+      <version>
+        <release>1.6.1</release>
+        <api>1.6.0</api>
+      </version>
+      <stability>
+        <release>stable</release>
+        <api>stable</api>
+      </stability>
+      <license uri="http://www.php.net/license">PHP</license>
+      <notes><![CDATA[
+  Fix: bug #64652 where Event::__construct returned valid object, however, with
+  uninitialized internal struct which caused segmentation faults in further
+  method calls
+  ]]></notes>
+    </release>
+    <!--}}}-->
     <!--{{{ 1.6.0 -->
     <release>
       <version>
 #ifndef PHP_EVENT_H
 #define PHP_EVENT_H
 
-#define PHP_EVENT_VERSION "1.6.0"
+#define PHP_EVENT_VERSION "1.6.1"
 
 #define PHP_EVENT_SUN_PREFIX "unix:"
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.