From de174daaae9c835387295c8bad6b761b3289e4dc Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 29 Jul 2014 20:37:00 +0200 Subject: [PATCH] alloca --- php_http_message.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/php_http_message.c b/php_http_message.c index 9432ae9..cc04edc 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -149,7 +149,13 @@ php_http_message_t *php_http_message_parse(php_http_message_t *msg, const char * zval *php_http_message_header(php_http_message_t *msg, const char *key_str, size_t key_len, int join) { zval *ret = NULL, **header; - char *key = php_http_pretty_key(estrndup(key_str, key_len), key_len, 1, 1); + char *key; + ALLOCA_FLAG(free_key); + + key = do_alloca(key_len + 1, free_key); + memcpy(key, key_str, key_len); + key[key_len] = '\0'; + php_http_pretty_key(key, key_len, 1, 1); if (SUCCESS == zend_symtable_find(&msg->hdrs, key, key_len + 1, (void *) &header)) { if (join && Z_TYPE_PP(header) == IS_ARRAY) { @@ -162,7 +168,7 @@ zval *php_http_message_header(php_http_message_t *msg, const char *key_str, size } } - efree(key); + free_alloca(key, free_key); return ret; } -- 2.30.2