Fix for a malloc problem in patch
Geoff Kuenning
geoff at desint.UUCP
Tue Nov 27 07:32:58 AEST 1984
In article <320 at rna.UUCP> dan at rna.UUCP (Dan Ts'o) writes:
> Alas things are still not well with patch - I occassionally get
>core dumps in malloc(), via savestr(), but I haven't had a chance to
>track that one down yet. It seems to happen when patch can't find the
>appropriate file, but it may be something else. Sigh... A valiant
>program, tho...
I have found a malloc bug in patch that made it completely unworkable on
my system. Hand-made context diff's follow; please no flames if they fail
to pass through 'patch'.
*** patch.c.orig Nov 25 01:56
--- patch.c Nov 26 13:02
***************
*** 753,759
if (*s == '\n')
iline++;
}
! i_ptr = (char **)malloc((iline + 1) * sizeof(char *));
if (i_ptr == Null(char **)) { /* shucks, it was a near thing */
free(i_womp);
return FALSE;
--- 753,759 -----
if (*s == '\n')
iline++;
}
! i_ptr = (char **)malloc((iline + 2) * sizeof(char *));
if (i_ptr == Null(char **)) { /* shucks, it was a near thing */
free(i_womp);
return FALSE;
--
Geoff Kuenning
...!ihnp4!trwrb!desint!geoff
More information about the Comp.sources.bugs
mailing list