tests/backtrace.c (frame_callback): Error on seeing more than 16 frames.

Don't fill up the test logs with obviously bogus frames.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 90a2a0e..dce6ebe 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2014-06-15  Mark Wielaard  <mjw@redhat.com>
+
+	* backtrace.c (frame_callback): Error on seeing more than 16 frames.
+
 2014-06-13  Mark Wielaard  <mjw@redhat.com>
 
 	* backtrace.c (callback_verify): Accept "__libc_do_syscall" as first
diff --git a/tests/backtrace.c b/tests/backtrace.c
index 1d3948e..331ba0f 100644
--- a/tests/backtrace.c
+++ b/tests/backtrace.c
@@ -148,6 +148,13 @@
   int *framenop = frame_arg;
   Dwarf_Addr pc;
   bool isactivation;
+
+  if (*framenop > 16)
+    {
+      error (0, 0, "Too many frames: %d\n", *framenop);
+      return DWARF_CB_ABORT;
+    }
+
   if (! dwfl_frame_pc (state, &pc, &isactivation))
     {
       error (0, 0, "%s", dwfl_errmsg (-1));