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

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