- 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 45be49b489774b604eaa61666695941cfa2ad7de..b6d8de21a0d8cbdb293229e8a965cc1b20d7430f 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;
+                       }
                }
        }
 }