- fix SEGV on prematurely called HttpMessage::next()
authorMichael Wallner <mike@php.net>
Wed, 3 Oct 2007 06:26:02 +0000 (06:26 +0000)
committerMichael Wallner <mike@php.net>
Wed, 3 Oct 2007 06:26:02 +0000 (06:26 +0000)
http_message_object.c

index 45be49b..b6d8de2 100644 (file)
@@ -1494,16 +1494,18 @@ PHP_METHOD(HttpMessage, next)
 {
        NO_ARGS {
                getObject(http_message_object, obj);
-               getObjectEx(http_message_object, itr, obj->iterator);
-               
-               if (itr && itr->parent.handle) {
-                       zval *old = obj->iterator;
-                       MAKE_STD_ZVAL(obj->iterator);
-                       ZVAL_OBJVAL(obj->iterator, itr->parent, 1);
-                       zval_ptr_dtor(&old);
-               } else {
-                       zval_ptr_dtor(&obj->iterator);
-                       obj->iterator = NULL;
+               if (obj->iterator) {
+                       getObjectEx(http_message_object, itr, obj->iterator);
+                       
+                       if (itr && itr->parent.handle) {
+                               zval *old = obj->iterator;
+                               MAKE_STD_ZVAL(obj->iterator);
+                               ZVAL_OBJVAL(obj->iterator, itr->parent, 1);
+                               zval_ptr_dtor(&old);
+                       } else {
+                               zval_ptr_dtor(&obj->iterator);
+                               obj->iterator = NULL;
+                       }
                }
        }
 }