From: Michael Wallner Date: Tue, 26 Apr 2005 12:17:10 +0000 (+0000) Subject: - memleaks & error messages X-Git-Tag: RELEASE_0_8_0~56 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=d9977f6aacc9e424366bc80d6d252f45e23bdc0f;p=m6w6%2Fext-http - memleaks & error messages --- diff --git a/http_message_object.c b/http_message_object.c index 0f72351..fee935e 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -266,7 +266,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va msg->info.request.URI = NULL; } } - + break; case HTTP_MSG_PROPHASH_HTTP_VERSION: @@ -324,6 +324,8 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va } break; } + zval_dtor(value); + FREE_ZVAL(value); } static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC) diff --git a/http_methods.c b/http_methods.c index 6900604..6558b4f 100644 --- a/http_methods.c +++ b/http_methods.c @@ -782,6 +782,10 @@ PHP_METHOD(HttpMessage, setRequestMethod) if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &method, &method_len)) { RETURN_FALSE; } + if (method_len < 1) { + http_error(E_WARNING, HTTP_E_PARAM, "Cannot set HttpMessage::requestMethod to an empty string"); + RETURN_FALSE; + } UPD_PROP(obj, string, requestMethod, method); RETURN_TRUE; @@ -828,7 +832,7 @@ PHP_METHOD(HttpMessage, setRequestUri) RETURN_FALSE; } if (URIlen < 1) { - http_error(E_WARNING, HTTP_E_PARAM, "Cannot set HttpMessage::requestMethod to an empty string"); + http_error(E_WARNING, HTTP_E_PARAM, "Cannot set HttpMessage::requestUri to an empty string"); RETURN_FALSE; } @@ -867,22 +871,22 @@ PHP_METHOD(HttpMessage, getHttpVersion) */ PHP_METHOD(HttpMessage, setHttpVersion) { - zval *v; - zval *version; + char v[4]; + zval *zv, *version; getObject(http_message_object, obj); - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &v)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zv)) { return; } - convert_to_string_ex(&v); - if (strcmp(Z_STRVAL_P(v), "1.0") && strcmp(Z_STRVAL_P(v), "1.1")) { - http_error_ex(E_WARNING, HTTP_E_PARAM, "Invalid HTTP version (1.0 or 1.1): %s", Z_STRVAL_P(v)); + convert_to_double_ex(&zv); + sprintf(v, "%1.1f", Z_DVAL_P(zv)); + if (strcmp(v, "1.0") && strcmp(v, "1.1")) { + http_error_ex(E_WARNING, HTTP_E_PARAM, "Invalid HTTP version (1.0 or 1.1): %s", v); RETURN_FALSE; } - convert_to_double_ex(&v); - SET_PROP(obj, httpVersion, v); + SET_PROP(obj, httpVersion, zv); } /* }}} */