about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-22 10:09:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-22 10:09:09 -0700
commit7d13531e531541fd1593b1bf6e410a5589afb46d (patch)
treec2a4561f757022c36a13b2e5ef8dccdf0cefdd20
parent0a3bc57c4f060363c98721955f4f77dcf92444f9 (diff)
downloadmu-7d13531e531541fd1593b1bf6e410a5589afb46d.tar.gz
1122 - another potential out of bounds access
My methodology of tracing and testing isn't intended to eliminate
undefined behavior. But mu will, eventually.
-rw-r--r--cpp/001test8
1 files changed, 6 insertions, 2 deletions
diff --git a/cpp/001test b/cpp/001test
index 92cbe9cf..12352de1 100644
--- a/cpp/001test
+++ b/cpp/001test
@@ -64,13 +64,17 @@ if (argc > 2 && is_equal(argv[1], "test")) {
 void run_tests() {
   time_t t; time(&t);
   cerr << "C tests: " << ctime(&t);
-  for (unsigned long i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) {
+  for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) {
     run_test(i);
   }
   // End Tests
 }
 
-void run_test(int i) {
+void run_test(size_t i) {
+  if (i >= sizeof(Tests)/sizeof(Tests[0])) {
+    cerr << "no test " << i << '\n';
+    return;
+  }
   setup();
   // End Test Setup
   (*Tests[i])();