- php_http_message_parser_parse(&p, &buf, PHP_HTTP_MESSAGE_PARSER_CLEANUP, &msg);
+
+ if ((free_msg = !msg)) {
+ msg = php_http_message_init(NULL, 0 TSRMLS_CC);
+ }
+
+ if (FAILURE == php_http_message_parser_parse(&p, &buf, PHP_HTTP_MESSAGE_PARSER_CLEANUP, &msg)) {
+ if (free_msg) {
+ php_http_message_free(&msg);
+ }
+ msg = NULL;
+ }
+