1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-13 09:01:53 +03:00

Applied a bug fix on file reading code from John Ellson <ellson@lucent.com>, Daniel.

This commit is contained in:
Daniel Veillard
1999-07-09 10:11:57 +00:00
parent 82150d8a99
commit 7cc3c04b80
3 changed files with 14 additions and 9 deletions

View File

@ -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);