[GRASS5] [patch] resize bug in X monitor

Magnus B{ckstr|m b at etek.chalmers.se
Tue Apr 30 13:45:06 EDT 2002


Hi,

the below patch corrects a bunnyhop error in XDRIVER and updates
G_malloc() a little.

The bunnyhop error caused a bus error when resizing an X monitor on
freebsd, and the update to G_malloc() ensures that returned memory
is initialized to zeros (which not all malloc()s can be trusted to
do).

Magnus

Index: src/display/devices/XDRIVER/XDRIVER24/Serve_Xevent.c
===================================================================
RCS file: /home/grass/grassrepository/grass/src/display/devices/XDRIVER/XDRIVER2
4/Serve_Xevent.c,v
retrieving revision 1.7
diff -c -r1.7 Serve_Xevent.c
*** src/display/devices/XDRIVER/XDRIVER24/Serve_Xevent.c        16 Feb 2002 07:2
2:56 -0000      1.7
--- src/display/devices/XDRIVER/XDRIVER24/Serve_Xevent.c        30 Apr 2002 17:1
8:15 -0000
***************
*** 234,240 ****
  
  static void handleResizeEvent(void)
  {
!     PAD *curpad;
      char buf[64];
      XWindowAttributes xwa;
      XGCValues gc_values;
--- 234,241 ----
  
  static void handleResizeEvent(void)
  {
!     FILE *_f;
!     PAD *curpad, *nextpad;
      char buf[64];
      XWindowAttributes xwa;
      XGCValues gc_values;
***************
*** 254,262 ****
      delete_item(curpad,"cur_w");
  
      /* delete all other pads */
!     for ( curpad = pad_list(); curpad != NULL; curpad = curpad->next )
        if ( *curpad->name  )
            delete_pad(curpad);
  
      curpad = NULL;
  
--- 255,266 ----
      delete_item(curpad,"cur_w");
  
      /* delete all other pads */
!     for ( curpad = pad_list(); curpad != NULL; curpad = nextpad )
!     {
!       nextpad = curpad->next;
        if ( *curpad->name  )
            delete_pad(curpad);
+     }
  
      curpad = NULL;
  
Index: src/libes/gis/alloc.c
===================================================================
RCS file: /home/grass/grassrepository/grass/src/libes/gis/alloc.c,v
retrieving revision 1.2
diff -c -r1.2 alloc.c
*** src/libes/gis/alloc.c       22 Jan 2002 12:01:06 -0000      1.2
--- src/libes/gis/alloc.c       30 Apr 2002 17:18:45 -0000
***************
*** 59,65 ****
      if (n <= 0) n = 1;        /* make sure we get a valid request */
  
      buf = malloc(n);
!     if(buf) return buf;
  
      G_fatal_error ("G_malloc: out of memory");
      return NULL;
--- 59,68 ----
      if (n <= 0) n = 1;        /* make sure we get a valid request */
  
      buf = malloc(n);
!     if(buf) {
!       bzero(buf, n);  /* Don't trust malloc to initialize buffer. */
!       return buf;
!     }
  
      G_fatal_error ("G_malloc: out of memory");
      return NULL;






More information about the grass-dev mailing list