From 067c2dd6b24755ec71f531636af53443866105bd Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 12 Jun 2002 03:01:30 +0000 Subject: [PATCH] globals.c: don't crash on bad function numbers qfprogs.c: if the file doesn't load first try, thy appending .gz --- tools/qfprogs/source/globals.c | 15 ++++++++++----- tools/qfprogs/source/qfprogs.c | 9 +++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/qfprogs/source/globals.c b/tools/qfprogs/source/globals.c index a3513f472..e7c506396 100644 --- a/tools/qfprogs/source/globals.c +++ b/tools/qfprogs/source/globals.c @@ -67,11 +67,16 @@ dump_globals (progs_t *pr) if (def->type == ev_func) { func_t func = G_FUNCTION (pr, offset); - int start = pr->pr_functions[func].first_statement; - if (start > 0) - comment = va (" %d @ %d", func, start); - else - comment = va (" %d = #%d", func, -start); + int start; + if (func >= 0 && func < pr->progs->numfunctions) { + start = pr->pr_functions[func].first_statement; + if (start > 0) + comment = va (" %d @ %d", func, start); + else + comment = va (" %d = #%d", func, -start); + } else { + comment = va (" %d = illegal function", func); + } } printf ("%s %d %d %s%s\n", type, saveglobal, offset, name, comment); diff --git a/tools/qfprogs/source/qfprogs.c b/tools/qfprogs/source/qfprogs.c index 3eafa753f..01db2fded 100644 --- a/tools/qfprogs/source/qfprogs.c +++ b/tools/qfprogs/source/qfprogs.c @@ -52,11 +52,10 @@ static const char rcsid[] = #include "QF/pr_comp.h" #include "QF/progs.h" #include "QF/sys.h" +#include "QF/va.h" #include "QF/vfile.h" #include "QF/zone.h" -#include "QF/vfile.h" - #include "disassemble.h" #include "globals.h" #include "strings.h" @@ -115,8 +114,10 @@ load_file (progs_t *pr, const char *name) file = open_file (name, &size); if (!file) { - perror (name); - return 0; + file = open_file (va ("%s.gz", name), &size); + if (!file) { + return 0; + } } sym = malloc (size); Qread (file, sym, size);