From 9ebfcd40b777ee7d69b0b422fd98342bee39e10a Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 24 Jan 2007 09:29:42 +0000 Subject: [PATCH] - fix segvs with incompletely initialiezed HttpMessages --- http_message_object.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/http_message_object.c b/http_message_object.c index 235ffc4..e2dbb56 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -905,7 +905,11 @@ PHP_METHOD(HttpMessage, getResponseStatus) if (return_value_used) { getObject(http_message_object, obj); HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj->message, RETURN_FALSE); - RETURN_STRING(obj->message->http.info.response.status, 1); + if (obj->message->http.info.response.status) { + RETURN_STRING(obj->message->http.info.response.status, 1); + } else { + RETURN_EMPTY_STRING(); + } } } /* }}} */ @@ -923,7 +927,7 @@ PHP_METHOD(HttpMessage, setResponseStatus) if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &status, &status_len)) { RETURN_FALSE; } - STR_SET(obj->message->http.info.response.status, estrdup(status)); + STR_SET(obj->message->http.info.response.status, estrndup(status, status_len)); RETURN_TRUE; } /* }}} */ @@ -937,7 +941,11 @@ PHP_METHOD(HttpMessage, getRequestMethod) if (return_value_used) { getObject(http_message_object, obj); HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE); - RETURN_STRING(obj->message->http.info.request.method, 1); + if (obj->message->http.info.request.method) { + RETURN_STRING(obj->message->http.info.request.method, 1); + } else { + RETURN_EMPTY_STRING(); + } } } /* }}} */ @@ -978,7 +986,11 @@ PHP_METHOD(HttpMessage, getRequestUrl) if (return_value_used) { getObject(http_message_object, obj); HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE); - RETURN_STRING(obj->message->http.info.request.url, 1); + if (obj->message->http.info.request.url) { + RETURN_STRING(obj->message->http.info.request.url, 1); + } else { + RETURN_EMPTY_STRING(); + } } } /* }}} */ -- 2.30.2