[comp.sources.games.bugs] xconq bugfix for standing orders

leres@ace.ee.lbl.gov (Craig Leres) (07/25/88)

I guess since I'm used to VMS empire, I tend to give cities standing
orders; this probably explains why I was unable to play a game of xconq
without having "core dumped" finish me off before actually engaging the
enemy. This problem is in get_standing_order(); you've got to zero the
memory malloc'ed for the array of Order pointers.

Appended is the context diff for my unofficial patch.

		Craig

P.S. I looked around for other errors of this class, but didn't see any
obvious ones.
------
RCS file: RCS/do.c,v
retrieving revision 1.1
diff -c -r1.1 do.c
*** /tmp/,RCSt1a01811	Mon Jul 25 03:00:57 1988
--- do.c	Mon Jul 25 02:59:59 1988
***************
*** 2,8 ****
  /* This program may be used, copied, modified, and redistributed freely */
  /* for noncommercial purposes, so long as this notice remains intact. */
  
! /* RCS $Header: do.c,v 1.1 88/07/24 21:20:03 leres Exp $ */
  
  /* This file contains almost all command functions. */
  /* Help commands are in a separate file. */
--- 2,8 ----
  /* This program may be used, copied, modified, and redistributed freely */
  /* for noncommercial purposes, so long as this notice remains intact. */
  
! /* RCS $Header: do.c,v 1.2 88/07/25 02:59:18 leres Exp $ */
  
  /* This file contains almost all command functions. */
  /* Help commands are in a separate file. */
***************
*** 931,940 ****
--- 931,942 ----
      if (side->requnit->standing == NULL) {
  	side->requnit->standing =
  	    (StandingOrder *) malloc(sizeof(StandingOrder));
+ 	    bzero((char *)side->requnit->standing, sizeof(StandingOrder));
      }
      side->teach = TRUE;
      side->soutype = type;
      side->tmporder = (Order *) malloc(sizeof(Order));
+     bzero((char *)side->tmporder, sizeof(Order));
      notify(side, "Next input order will become the standing order.");
      show_timemode(side);
      request_command(side);