Complete.Org: Mailing Lists: Archives: freeciv-dev: November 1998:
Re: [Freeciv-Dev] civclient quits without warning
Home

Re: [Freeciv-Dev] civclient quits without warning

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: andrex@xxxxxxxxxxx, Kris.Bubendorfer@xxxxxxxxxxxxx
Subject: Re: [Freeciv-Dev] civclient quits without warning
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Thu, 12 Nov 1998 11:25:07 +1100

(Andrew Schulman wrote:)
> > The civclient has a nasty tendency to suddenly quit, causing me to lose a
> > turn.  I've noticed this before after I used "Investigate city" in the
> > diplomat dialog, but in the CVS version of 10/31 it just did it to me after
> > an ordinary attack.  Has anyone else noticed this?
> 
Kris Bubendorfer wrote:
> Yes.  Mine is dying in void meswin_allocate(void) with a realloc problem.  It 
> is quite independent of `diplomat investigate' because it happens anyway 
> although choosing investigate almost guarantees a crash.

Could those who have had this problem please check if this patch
helps, and let me know?  I think the patch is correct as far as it
goes, but it would be nice to know if it fixes that particular problem.

-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/messagewin.c 
freeciv-mod/client/messagewin.c
--- freeciv-cvs/client/messagewin.c     Tue Nov 10 21:37:56 1998
+++ freeciv-mod/client/messagewin.c     Thu Nov 12 01:01:35 1998
@@ -186,9 +186,9 @@
 static int *ypos = NULL;
 
 /**************************************************************************
- This can be called:
- - when we want to use string_ptrs[0] before we add any messages.
- - when the number allocated might need to grow due to adding more messages.
+ This makes sure that the next two elements in string_ptrs etc are
+ allocated for.  Two = one to be able to grow, and one for the sentinel
+ in string_ptrs.
  Note update_meswin_dialog should always be called soon after this since
  it contains pointers to the memory we're reallocing here.
 **************************************************************************/
@@ -196,7 +196,7 @@
 {
   int i;
   
-  if (messages_total>=messages_alloc) {
+  if (messages_total+2 > messages_alloc) {
     messages_alloc = messages_total + 32;
     string_ptrs = realloc(string_ptrs, messages_alloc*sizeof(char*));
     xpos = realloc(xpos, messages_alloc*sizeof(int));

[Prev in Thread] Current Thread [Next in Thread]