[news.software.b] sortactive

dave@onfcanim.UUCP (Dave Martindale) (12/19/86)

The function sortactive() in rfuncs.c reads stuff into a structure
pointed to by "tp".  Unfortunately, the code that initializes "tp"
is compiled in only if SORTACTIVE is defined.  Without it, some
random memory is stomped.  In my case, it was the end of argv and the
beginning of the environment.  There is no visible effect of the error
until you execute a command (like 'c') that forks to do its work,
at which point someone complains about the format of the environment.

The fix is trivial - move the initialization outside the conditional code:

*** /tmp/oldrfuncs.c	Mon Nov 10 23:20:41 1986
--- ./rfuncs.c	Thu Dec 18 21:52:35 1986
***************
*** 618,624
  	p = ACTIVE;
  	ACTIVE = newactivename;
  	afp = xfopen(p, "r");
- 	tp = table;
  #else /* !SORTACTIVE */
  	afp = xfopen(ACTIVE, "r");
  #endif /* !SORTACTIVE */

--- 618,623 -----
  	p = ACTIVE;
  	ACTIVE = newactivename;
  	afp = xfopen(p, "r");
  #else /* !SORTACTIVE */
  	afp = xfopen(ACTIVE, "r");
  #endif /* !SORTACTIVE */
***************
*** 622,627
  #else /* !SORTACTIVE */
  	afp = xfopen(ACTIVE, "r");
  #endif /* !SORTACTIVE */
  	while (fgets(aline, sizeof aline, afp) != NULL) {
  		if (sscanf(aline,"%s %ld %ld %c", ngname, &tp->maxart,
  		    &tp->minart, &tp->yn) != 4) 

--- 621,627 -----
  #else /* !SORTACTIVE */
  	afp = xfopen(ACTIVE, "r");
  #endif /* !SORTACTIVE */
+ 	tp = table;
  	while (fgets(aline, sizeof aline, afp) != NULL) {
  		if (sscanf(aline,"%s %ld %ld %c", ngname, &tp->maxart,
  		    &tp->minart, &tp->yn) != 4)