mike Mon Oct 17 10:19:33 2005 EDT
Modified files:
/pecl/http http_encoding_api.c http_send_api.c
/pecl/http/phpstr phpstr.c
/pecl/http/tests send_data_008.phpt
Log:
- fix remaining issues; there's still a 1-byte memleak I could not find yet
http://cvs.php.net/diff.php/pecl/http/http_encoding_api.c?r1=1.13&r2=1.14&ty=u
Index: pecl/http/http_encoding_api.c
diff -u pecl/http/http_encoding_api.c:1.13 pecl/http/http_encoding_api.c:1.14
--- pecl/http/http_encoding_api.c:1.13 Mon Oct 17 09:46:00 2005
+++ pecl/http/http_encoding_api.c Mon Oct 17 10:19:17 2005
@@ -13,7 +13,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: http_encoding_api.c,v 1.13 2005/10/17 13:46:00 mike Exp $ */
+/* $Id: http_encoding_api.c,v 1.14 2005/10/17 14:19:17 mike Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -151,13 +151,13 @@
*buf_ptr = emalloc(*buf_len + 1);
} else {
size_t new_len = *buf_len << 2;
- char *new_ptr = erealloc(*buf_ptr, new_len + 1);
+ char *new_ptr = erealloc_recoverable(*buf_ptr, new_len + 1);
if (new_ptr) {
*buf_ptr = new_ptr;
*buf_len = new_len;
} else {
- *iteration = INT_MAX;
+ *iteration = INT_MAX-1; /* avoid integer overflow on
increment op */
}
}
}
@@ -602,6 +602,8 @@
add_next_index_stringl(&zsupported, "gzip",
lenof("gzip"), 1);
add_next_index_stringl(&zsupported, "deflate",
lenof("deflate"), 1);
+ HTTP_G(send).gzip_encoding = 0;
+
if (selected = http_negotiate_encoding(&zsupported)) {
STATUS hs = FAILURE;
char *encoding = NULL;
@@ -619,8 +621,6 @@
}
if (SUCCESS == hs) {
http_send_header_string("Vary:
Accept-Encoding");
- } else {
- HTTP_G(send).gzip_encoding = 0;
}
}
@@ -629,7 +629,7 @@
}
zval_dtor(&zsupported);
- return 1;
+ return HTTP_G(send).gzip_encoding;
#endif
}
}
http://cvs.php.net/diff.php/pecl/http/http_send_api.c?r1=1.30&r2=1.31&ty=u
Index: pecl/http/http_send_api.c
diff -u pecl/http/http_send_api.c:1.30 pecl/http/http_send_api.c:1.31
--- pecl/http/http_send_api.c:1.30 Mon Oct 17 09:46:00 2005
+++ pecl/http/http_send_api.c Mon Oct 17 10:19:17 2005
@@ -13,7 +13,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: http_send_api.c,v 1.30 2005/10/17 13:46:00 mike Exp $ */
+/* $Id: http_send_api.c,v 1.31 2005/10/17 14:19:17 mike Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -100,7 +100,7 @@
http_encoding_stream *s = *((http_encoding_stream **) buffer);
http_encoding_stream_update(s, data, data_len, &encoded,
&encoded_len);
- phpstr_chunked_output(&s->storage, data, data_len,
HTTP_G(send).buffer_size, _http_flush TSRMLS_CC);
+ phpstr_chunked_output(&s->storage, encoded, encoded_len,
HTTP_G(send).buffer_size, _http_flush TSRMLS_CC);
efree(encoded);
#else
http_error(HE_ERROR, HTTP_E_RESPONSE, "Attempt to send GZIP
response despite being able to do so; please report this bug");
@@ -167,18 +167,19 @@
if (HTTP_G(send).gzip_encoding) {
#ifdef HTTP_HAVE_ZLIB
char *encoded = NULL;
- size_t encoded_len;
+ size_t encoded_len = 0;
http_encoding_stream *s = *((http_encoding_stream **) buffer);
http_encoding_stream_finish(s, &encoded, &encoded_len);
- buffer = &s->storage;
- phpstr_chunked_output((phpstr **) buffer, encoded, encoded_len,
HTTP_G(send).buffer_size, _http_flush TSRMLS_CC);
+ phpstr_chunked_output(&s->storage, encoded, encoded_len, 0,
_http_flush TSRMLS_CC);
STR_FREE(encoded);
+ efree(s);
#else
http_error(HE_ERROR, HTTP_E_RESPONSE, "Attempt to send GZIP
response despite being able to do so; please report this bug");
#endif
+ } else {
+ phpstr_chunked_output((phpstr **) buffer, NULL, 0, 0,
_http_flush TSRMLS_CC);
}
- phpstr_chunked_output((phpstr **) buffer, NULL, 0, 0, _http_flush
TSRMLS_CC);
}
/* }}} */
http://cvs.php.net/diff.php/pecl/http/phpstr/phpstr.c?r1=1.9&r2=1.10&ty=u
Index: pecl/http/phpstr/phpstr.c
diff -u pecl/http/phpstr/phpstr.c:1.9 pecl/http/phpstr/phpstr.c:1.10
--- pecl/http/phpstr/phpstr.c:1.9 Mon Oct 17 09:46:01 2005
+++ pecl/http/phpstr/phpstr.c Mon Oct 17 10:19:20 2005
@@ -1,5 +1,5 @@
-/* $Id: phpstr.c,v 1.9 2005/10/17 13:46:01 mike Exp $ */
+/* $Id: phpstr.c,v 1.10 2005/10/17 14:19:20 mike Exp $ */
#include "php.h"
#include "phpstr.h"
@@ -262,7 +262,7 @@
if (!chunk_size) {
phpstr_data(storage, chunk, &chunk_size);
- phpstr_free(&storage);
+ phpstr_free(s);
return chunk_size;
}
@@ -288,6 +288,8 @@
data = NULL;
data_len = 0;
if (!chunk_len) {
+ /* we already got the last chunk,
+ and freed all resources */
break;
}
}
http://cvs.php.net/diff.php/pecl/http/tests/send_data_008.phpt?r1=1.4&r2=1.5&ty=u
Index: pecl/http/tests/send_data_008.phpt
diff -u pecl/http/tests/send_data_008.phpt:1.4
pecl/http/tests/send_data_008.phpt:1.5
--- pecl/http/tests/send_data_008.phpt:1.4 Fri Aug 19 10:56:52 2005
+++ pecl/http/tests/send_data_008.phpt Mon Oct 17 10:19:20 2005
@@ -7,7 +7,7 @@
?>
--FILE--
<?php
-http_throttle(0.01, 20);
+http_throttle(0.01, 1);
http_send_data('00000000000000000000');
?>
--EXPECTF--
|