1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-01 10:06:59 +03:00

Fixed? a trange bug related to compression, Daniel.

This commit is contained in:
Daniel Veillard
1998-10-30 06:39:40 +00:00
parent 25940b7c1b
commit 27271682f7
2 changed files with 14 additions and 6 deletions

View File

@ -1,3 +1,8 @@
Fri Oct 30 01:36:52 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* parser.c: fixed? a strange error due to compression on a GWP
document.
Thu Oct 29 00:48:45 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org> Thu Oct 29 00:48:45 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* tree.[ch]: bug fixing * tree.[ch]: bug fixing

View File

@ -3345,6 +3345,7 @@ xmlDocPtr xmlParseFile(const char *filename) {
int input; int input;
#endif #endif
int res; int res;
int len;
struct stat buf; struct stat buf;
char *buffer; char *buffer;
xmlParserCtxtPtr ctxt; xmlParserCtxtPtr ctxt;
@ -3354,17 +3355,19 @@ xmlDocPtr xmlParseFile(const char *filename) {
if (res < 0) return(NULL); if (res < 0) return(NULL);
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
len = (buf.st_size * 8) + 1000;
retry_bigger: retry_bigger:
buffer = malloc((buf.st_size * 20) + 100); buffer = malloc(len);
#else #else
buffer = malloc(buf.st_size + 100); len = buf.st_size + 100;
buffer = malloc(len);
#endif #endif
if (buffer == NULL) { if (buffer == NULL) {
perror("malloc"); perror("malloc");
return(NULL); return(NULL);
} }
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, len);
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
input = gzopen (filename, "r"); input = gzopen (filename, "r");
if (input == NULL) { if (input == NULL) {
@ -3381,7 +3384,7 @@ retry_bigger:
} }
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
res = gzread(input, buffer, 20 * buf.st_size); res = gzread(input, buffer, len);
#else #else
res = read(input, buffer, buf.st_size); res = read(input, buffer, buf.st_size);
#endif #endif
@ -3396,9 +3399,9 @@ retry_bigger:
} }
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
gzclose(input); gzclose(input);
if (res >= 20 * buf.st_size + 20) { if (res >= len) {
free(buffer); free(buffer);
buf.st_size *= 2; len *= 2;
goto retry_bigger; goto retry_bigger;
} }
buf.st_size = res; buf.st_size = res;