summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2007-06-13 20:47:19 +0200
committerMike Hommey <glandium@debian.org>2007-06-13 20:47:19 +0200
commit58f9d16e3a77d5207d9ccc413b61e2cb45190018 (patch)
treef190471ceb2bc35c076cc65159141813da73c8ee /encoding.c
parent789259a1b6850d30acffbb62b11456b9ed7a8f59 (diff)
downloadlibxml2-58f9d16e3a77d5207d9ccc413b61e2cb45190018.tar.gz
Load /tmp/libxml2-2.6.29 intoupstream/2.6.29.dfsg
libxml2/branches/upstream/current.
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/encoding.c b/encoding.c
index ee33df1..002eeba 100644
--- a/encoding.c
+++ b/encoding.c
@@ -1761,19 +1761,20 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
if (out == NULL) return(-1);
if (in == NULL) return(-1);
+ /* calculate space available */
written = out->size - out->use;
toconv = in->use;
- if (toconv * 2 >= written) {
- xmlBufferGrow(out, toconv);
- written = out->size - out->use - 1;
- }
-
/*
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
* 45 chars should be sufficient to reach the end of the encoding
* declaration without going too far inside the document content.
*/
- written = 45;
+ if (toconv > 45)
+ toconv = 45;
+ if (toconv * 2 >= written) {
+ xmlBufferGrow(out, toconv);
+ written = out->size - out->use - 1;
+ }
if (handler->input != NULL) {
ret = handler->input(&out->content[out->use], &written,