[Patches] pcre stack finalization

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Fri, 18 Feb 2000 20:04:36 +0100 (CET)


The same problem (mixed mallocs) exists for the pcre stack.

The buffers md->... are allocated via PyMem_RESIZE in grow_stack(),
while in free_stack() they are released with free() instead of PyMem_DEL.

This patch fixes it.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252

--
I confirm that, to the best of my knowledge and belief, this contribution is
free of any claims of third parties under copyright, patent or other rights
or interests ("claims").  To the extent that I have any such claims, I
hereby grant to CNRI a nonexclusive, irrevocable, royalty-free, worldwide
license to reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part of the
Python software and its related documentation, or any derivative versions
thereof, at no cost to CNRI or its licensed users, and to authorize others
to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or not
to incorporate this contribution in the Python software and its related
documentation.  I further grant CNRI permission to use my name and other
identifying information provided to CNRI by me for use in connection with
the Python software and its related documentation.

-------------------------------[ cut here ]---------------------------  
diff -cr Python-1.5.2/Modules/pypcre.c Python-1.5.2_PyMem/Modules/pypcre.c
*** Python-1.5.2/Modules/pypcre.c	Fri Feb 11 13:34:57 2000
--- Python-1.5.2_PyMem/Modules/pypcre.c	Sun Feb 13 15:23:47 2000
***************
*** 3057,3068 ****
  static int free_stack(match_data *md)
  {
  /* Free any stack space that was allocated by the call to match(). */
! if (md->off_num)    free(md->off_num); 
! if (md->offset_top) free(md->offset_top); 
! if (md->r1)         free(md->r1); 
! if (md->r2)         free(md->r2); 
! if (md->eptr)       free((char *)md->eptr); 
! if (md->ecode)      free((char *)md->ecode);
  return 0;
  }
  
--- 3058,3069 ----
  static int free_stack(match_data *md)
  {
  /* Free any stack space that was allocated by the call to match(). */
! if (md->off_num)    PyMem_DEL(md->off_num); 
! if (md->offset_top) PyMem_DEL(md->offset_top); 
! if (md->r1)         PyMem_DEL(md->r1); 
! if (md->r2)         PyMem_DEL(md->r2); 
! if (md->eptr)       PyMem_DEL((char *)md->eptr); 
! if (md->ecode)      PyMem_DEL((char *)md->ecode);
  return 0;
  }