konijn@ace.UUCP (03/24/87)
Index: /usr/src/new/mh/uip/replsbr.c Description: The repl(1) command, part of MH-6.4, dumps core on mc68000 machines. The command allocates an array of pointers, with each pointer pointing to an allocated buffer. The buffers are freed by a loop that stops on the first NULL pointer. This happens to work OK on a VAX, presumably because calloc() returns a larger piece of memory than was requested. On my machine it doesn't. Repeat-By: Use repl(1) on an mc68000 machine. Fix: A quick hack: calloc() an extra field in the array of pointers. This field is initialised to NULL and will end the loop that frees all allocated buffers. *** replsbr.c Fri Mar 20 15:51:00 1987 --- /tmp/1 Fri Mar 20 19:44:03 1987 *************** *** 71,78 **** cp = new_fs (form ? form : replcomps, NULLCP, NULLCP); format_len = strlen (cp); ncomps = fmt_compile (cp, &fmt) + 1; ! /* allocate one extra pointer, null to stop freeing loop */ ! nxtbuf = compbuffers = (char **)calloc((unsigned)(ncomps+1),sizeof(char *)); if (nxtbuf == NULL) adios (NULLCP, "unable to allocate component buffers"); used_buf = (struct comp **)calloc((unsigned)(ncomps+1),sizeof(struct comp *)); --- 71,77 ---- cp = new_fs (form ? form : replcomps, NULLCP, NULLCP); format_len = strlen (cp); ncomps = fmt_compile (cp, &fmt) + 1; ! nxtbuf = compbuffers = (char **)calloc((unsigned)ncomps,sizeof(char *)); if (nxtbuf == NULL) adios (NULLCP, "unable to allocate component buffers"); used_buf = (struct comp **)calloc((unsigned)(ncomps+1),sizeof(struct comp *)); --------- Erik van Konijnenburg, <konijn@ace.nl>, ...!mcvax!ace!konijn, ACE Associated Computer Experts bv, Amsterdam, the Netherlands