Important patch for cmulisp-regex
- Subject: Important patch for cmulisp-regex
- From: Raymond Toy
- Date: 17 Apr 2001 19:10:02 -0400
Here is an important patch for cmulisp-regex.lisp. Without it, the
regex routines can corrupt cmucl's memory.
Ray
P.S. Is it appropriate to submit patches via this list?
Changelog:
Fix allocation/deallocation of regex registers to prevent memory
corruption
Patch:
--- maxima-clean/maxima/src/cmulisp-regex.lisp Fri Apr 6 18:39:31 2001
+++ maxima/src/cmulisp-regex.lisp Tue Apr 17 15:32:51 2001
@@ -228,14 +228,24 @@
re-regs))
(defun allocate-re-regs ()
- (make-alien re-registers 1))
+ (let ((regs (make-alien re-registers 1)))
+ (setf (slot (deref regs) 'num-regs) 0)
+ regs))
+
(defun free-re-regs (re-regs)
(declare (type (alien (* re-registers)) re-regs))
+
(let ((r (deref re-regs)))
- (free-alien (slot r 'start))
- (free-alien (slot r 'end))
- (free-alien re-regs)))
+ ;;(format t "freeing ~A:~%" re-regs)
+ ;;(format t " num-regs: ~A~%" (slot r 'num-regs))
+ (when (plusp (slot r 'num-regs))
+ ;;(format t " free start: ~A~%" (slot r 'start))
+ ;;(format t " free end: ~A~%" (slot r 'end))
+ (free-alien (slot r 'start))
+ (free-alien (slot r 'end))
+ (free-alien re-regs)
+ )))
(defun make-case-fold-table ()
"Translation table to fold all uppercase ASCII characters to lower