Source

pecl-event / src / pe.c

Diff from to

File src/pe.c

 #include "src/priv.h"
 #include "src/util.h"
 
+#define PHP_EVENT_PROP_REQUIRE(x) \
+	do {                          \
+		if (!(x)) return FAILURE; \
+	} while (0);
+
 static inline void _prop_write_zval(zval **ppz, const zval *value)
 {
 	if (!*ppz) {
 {
 	php_event_t *e = (php_event_t *) obj;
 
-	PHP_EVENT_ASSERT(e->event);
+	PHP_EVENT_PROP_REQUIRE(e->event);
 
 	MAKE_STD_ZVAL(*retval);
 	ZVAL_BOOL(*retval, (php_event_is_pending(e->event) ? 1 : 0));
 {
 	php_event_t *e = (php_event_t *) obj;
 
-	PHP_EVENT_ASSERT(e->event);
+	if (!e->event) return NULL;
 
 	return (e->data ? &e->data : NULL);
 }
 {
 	php_event_t *e = (php_event_t *) obj;
 
-	PHP_EVENT_ASSERT(e->event);
+	PHP_EVENT_PROP_REQUIRE(e->event);
 
 	_prop_read_zval(e->data, retval);
 
 {
 	php_event_t *e = (php_event_t *) obj;
 
-	PHP_EVENT_ASSERT(e->event);
+	PHP_EVENT_PROP_REQUIRE(e->event);
 
 	_prop_write_zval(&e->data, value);
 
 {
 	php_event_buffer_t *b = (php_event_buffer_t *) obj;
 
-	PHP_EVENT_ASSERT(b->buf);
+	PHP_EVENT_PROP_REQUIRE(b->buf);
 
 	MAKE_STD_ZVAL(*retval);
 	ZVAL_LONG(*retval, evbuffer_get_length(b->buf));
 {
 	php_event_buffer_t *b = (php_event_buffer_t *) obj;
 
-	PHP_EVENT_ASSERT(b->buf);
+	PHP_EVENT_PROP_REQUIRE(b->buf);
 
 	MAKE_STD_ZVAL(*retval);
 	ZVAL_LONG(*retval, evbuffer_get_contiguous_space(b->buf));
 	MAKE_STD_ZVAL(*retval);
 
 	/* Uninitialized / free'd */
+#if 0
 	if (!b->bevent) {
 		ZVAL_NULL(*retval);
 		return SUCCESS;
 	}
-	PHP_EVENT_ASSERT(b->bevent);
+#endif
+	PHP_EVENT_PROP_REQUIRE(b->bevent);
 
 	fd = bufferevent_getfd(b->bevent);
 	if (fd == -1) {