for review: bug fix for mdb `down' command

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Oct 28 16:59:11 AEDT 1998


Zoltan, could you please review this one?

--------------------

Fix a bug in mdb where the `down' command would let you go down
past the end of the stack.

runtime/mercury_stack_trace.c:
	Change MR_find_nth_ancestor() so that it returns an error string
	if the `n' that you give it is a negative number.

Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.18
diff -u -r1.18 mercury_stack_trace.c
--- mercury_stack_trace.c	1998/10/16 06:18:57	1.18
+++ mercury_stack_trace.c	1998/10/28 05:51:57
@@ -121,6 +121,11 @@
 	const MR_Stack_Layout_Label	*return_label_layout;
 	int				i;
 
+	if (ancestor_level < 0) {
+		*problem = "no such stack frame";
+		return NULL;
+	}
+
 	do_init_modules();
 	*problem = NULL;
 	for (i = 0; i < ancestor_level && label_layout != NULL; i++) {

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list