fix Bug #15509 HttpMessage::rewind memory leaks
[m6w6/ext-http] / http_message_object.c
index acb8a1d624dfccef96de6f27a252858e6081e7e3..88456812d7bffa33eb2f780c9b57455ce5b5cc0f 100644 (file)
@@ -393,6 +393,10 @@ void _http_message_object_free(zend_object *object TSRMLS_DC)
 {
        http_message_object *o = (http_message_object *) object;
 
+       if (o->iterator) {
+               zval_ptr_dtor(&o->iterator);
+               o->iterator = NULL;
+       }
        if (o->message) {
                http_message_dtor(o->message);
                efree(o->message);
@@ -418,7 +422,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type
 #else
        zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
        
-       if (!pinfo || ACC_PROP_PUBLIC(pinfo->flags)) {
+       if (!pinfo) {
                return zend_get_std_object_handlers()->read_property(object, member, type TSRMLS_CC);
        }
 #endif
@@ -511,11 +515,8 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type
                        break;
                
                default:
-#ifdef WONKY
+                       FREE_ZVAL(return_value);
                        return zend_get_std_object_handlers()->read_property(object, member, type TSRMLS_CC);
-#else
-                       RETVAL_NULL();
-#endif
        }
 
        return return_value;
@@ -531,7 +532,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va
 #else
        zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
        
-       if (!pinfo || ACC_PROP_PUBLIC(pinfo->flags)) {
+       if (!pinfo) {
                zend_get_std_object_handlers()->write_property(object, member, value TSRMLS_CC);
                return;
        }
@@ -617,9 +618,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va
                        break;
                
                default:
-#ifdef WONKY
                        zend_get_std_object_handlers()->write_property(object, member, value TSRMLS_CC);
-#endif
                        break;
        }
        if (cpy != value) {
@@ -1137,9 +1136,9 @@ PHP_METHOD(HttpMessage, setHttpVersion)
        }
 
        convert_to_double(zv);
-       sprintf(v, "%1.1lf", Z_DVAL_P(zv));
+       snprintf(v, sizeof(v), "%1.1f", Z_DVAL_P(zv));
        if (strcmp(v, "1.0") && strcmp(v, "1.1")) {
-               http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid HTTP protocol version (1.0 or 1.1): %s", v);
+               http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid HTTP protocol version (1.0 or 1.1): %g", Z_DVAL_P(zv));
                RETURN_FALSE;
        }
 
@@ -1401,8 +1400,8 @@ PHP_METHOD(HttpMessage, unserialize)
                if ((msg = http_message_parse_ex(obj->message, serialized, (size_t) length))) {
                        obj->message = msg;
                } else {
-                       http_error(HE_ERROR, HTTP_E_RUNTIME, "Could not unserialize HttpMessage");
                        http_message_init(obj->message);
+                       http_error(HE_ERROR, HTTP_E_RUNTIME, "Could not unserialize HttpMessage");
                }
        }
 }