diff --git a/ChangeLog b/ChangeLog index 85adc27a..2eb53ec0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 9 12:10:24 CEST 1999 Daniel Veillard + + * HTMLparser.c parser.c: applied patch from John Ellson + which fixed a problem on the file reading-code. + Wed Jul 7 09:28:43 CEST 1999 Daniel Veillard * 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); diff --git a/parser.c b/parser.c index d1cabbe5..7a47cd5f 100644 --- a/parser.c +++ b/parser.c @@ -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);