On Wed, Jul 02, 2014 at 02:11:11PM -0400, Ted Unangst wrote:

> On Wed, Jul 02, 2014 at 12:37, Otto Moerbeek wrote:
> > On Tue, Jul 01, 2014 at 03:56:39PM -0400, Jared Yanovich wrote:
> > 
> >> On Mon, Jun 30, 2014 at 11:53:04AM +0200, Otto Moerbeek wrote:
> >>
> >> > This indeed solves some problems, but I have a test file on which it
> > cores.
> >>
> >> Patch relative to the original diff I posted.
> >>
> >> diff -ru sort.new/fsort.c sort.new2/fsort.c
> >> --- sort.new/fsort.c       Tue Jul  1 15:54:45 2014
> >> +++ sort.new2/fsort.c      Tue Jul  1 15:55:15 2014
> >> @@ -62,7 +62,7 @@
> >>    static size_t bufsize;
> >>    int ntfiles, mfct = 0;
> >>    int c, nelem;
> >> -  union f_handle tfiles, mstart = { MAXFCT - MERGE_FNUM };
> >> +  union f_handle tfiles = { 0 }, mstart = { MAXFCT - MERGE_FNUM };
> >>    int (*get)(int, union f_handle, int, RECHEADER *,
> >>            u_char *, struct field *);
> >>    RECHEADER *crec;
> > 
> > This works better indeed. But is initing the int member only safe? If
> > sizeof(top) < sizeof(names), only init some bits of the pointer.
> 
> The size of the fields shouldn't matter. You can only read from the
> last written field. If you want to read names, you need to write it
> first.

That assumes the code does that right all the time.

        -Otto

Reply via email to