diff options
author | Daniel Veillard <veillard@src.gnome.org> | 1999-07-09 10:11:57 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 1999-07-09 10:11:57 +0000 |
commit | 7cc3c04b806cb29cdd2b7a8030615af8cad6738c (patch) | |
tree | 1943c891e12db556164880a3d0ea4baabc316c81 | |
parent | 82150d8a992e118970dc9067043bd2908ea061aa (diff) | |
download | libxml2-7cc3c04b806cb29cdd2b7a8030615af8cad6738c.tar.gz |
Applied a bug fix on file reading code from John Ellson <ellson@lucent.com>, Daniel.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | HTMLparser.c | 6 | ||||
-rw-r--r-- | parser.c | 12 |
3 files changed, 14 insertions, 9 deletions
@@ -1,3 +1,8 @@ +Fri Jul 9 12:10:24 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org> + + * HTMLparser.c parser.c: applied patch from John Ellson <ellson@lucent.com> + which fixed a problem on the file reading-code. + Wed Jul 7 09:28:43 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org> * HTMLparser.[ch], HTMLtree.[ch]: more work for HTML parsing and diff --git a/HTMLparser.c b/HTMLparser.c index 5259f6e8..aeb8bf71 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -2630,11 +2630,11 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding) res = stat(filename, &buf); if (res < 0) return(NULL); - len = buf.st_size + 1; + len = buf.st_size; if (len < MINLEN) len = MINLEN; } - buffer = (char *)malloc(len*sizeof(char)); + buffer = (char *)malloc((len+1)*sizeof(char)); if (buffer == NULL) { fprintf (stderr, "Cannot malloc\n"); perror ("malloc failed"); @@ -2649,7 +2649,7 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding) #endif if (cnt == len) { len *= 2; - nbuf = (char *)realloc(buffer,len*sizeof(char)); + nbuf = (char *)realloc(buffer,(len+1)*sizeof(char)); if (nbuf == NULL) { fprintf(stderr,"Cannot realloc\n"); free(buffer); @@ -316,11 +316,11 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { res = stat(filename, &buf); if (res < 0) return(NULL); - len = buf.st_size+1; + len = buf.st_size; if (len < MINLEN) len = MINLEN; } - buffer = (char *)malloc(len*sizeof(char)); + buffer = (char *)malloc((len+1)*sizeof(char)); if (buffer == NULL) { fprintf (stderr, "Cannot malloc\n"); perror ("malloc failed"); @@ -335,7 +335,7 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { #endif if (cnt >= len) { len *= 2; - nbuf = (char *)realloc(buffer,len*sizeof(char)); + nbuf = (char *)realloc(buffer,(len+1)*sizeof(char)); if (nbuf == NULL) { fprintf(stderr,"Cannot realloc\n"); free(buffer); @@ -4683,11 +4683,11 @@ xmlCreateFileParserCtxt(const char *filename) res = stat(filename, &buf); if (res < 0) return(NULL); - len = buf.st_size+1; + len = buf.st_size; if (len < MINLEN) len = MINLEN; } - buffer = (char *)malloc(len*sizeof(char)); + buffer = (char *)malloc((len+1)*sizeof(char)); if (buffer == NULL) { fprintf (stderr, "Cannot malloc\n"); perror ("malloc failed"); @@ -4702,7 +4702,7 @@ xmlCreateFileParserCtxt(const char *filename) #endif if (cnt == len) { len *= 2; - nbuf = (char *)realloc(buffer,len*sizeof(char)); + nbuf = (char *)realloc(buffer,(len+1)*sizeof(char)); if (nbuf == NULL) { fprintf(stderr,"Cannot realloc\n"); free(buffer); |