mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-04 10:30:52 +00:00
Add some safety checks to progs global dumping.
Getting segfaults in the debug tools is not fun :P Conflicts: tools/qfcc/source/dump_globals.c
This commit is contained in:
parent
cc24e2e67e
commit
7a2f7e8982
1 changed files with 66 additions and 56 deletions
|
@ -63,8 +63,10 @@ dump_def (progs_t *pr, ddef_t *def, int indent)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *type;
|
const char *type;
|
||||||
int offset;
|
pr_uint_t offset;
|
||||||
const char *comment;
|
const char *comment;
|
||||||
|
string_t string;
|
||||||
|
const char *str;
|
||||||
int saveglobal;
|
int saveglobal;
|
||||||
|
|
||||||
if (!def->type && !def->ofs && !def->s_name)
|
if (!def->type && !def->ofs && !def->s_name)
|
||||||
|
@ -75,14 +77,21 @@ dump_def (progs_t *pr, ddef_t *def, int indent)
|
||||||
saveglobal = (def->type & DEF_SAVEGLOBAL) != 0;
|
saveglobal = (def->type & DEF_SAVEGLOBAL) != 0;
|
||||||
offset = def->ofs;
|
offset = def->ofs;
|
||||||
|
|
||||||
comment = "";
|
comment = " invalid offset";
|
||||||
|
|
||||||
|
if (offset < pr->progs->numglobals) {
|
||||||
switch (def->type & ~DEF_SAVEGLOBAL) {
|
switch (def->type & ~DEF_SAVEGLOBAL) {
|
||||||
case ev_void:
|
case ev_void:
|
||||||
break;
|
break;
|
||||||
case ev_string:
|
case ev_string:
|
||||||
comment = va (" %d \"%s\"", G_INT (pr, offset),
|
string = G_INT (pr, offset);
|
||||||
quote_string (pr->pr_strings + G_INT (pr, offset)));
|
if (string < 0 || string >= pr->progs->numstrings) {
|
||||||
|
str = "invalid string offset";
|
||||||
|
comment = va (" %d %s", string, str);
|
||||||
|
} else {
|
||||||
|
str = quote_string (pr->pr_strings + G_INT (pr, offset));
|
||||||
|
comment = va (" %d \"%s\"", string, str);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ev_float:
|
case ev_float:
|
||||||
comment = va (" %g", G_FLOAT (pr, offset));
|
comment = va (" %g", G_FLOAT (pr, offset));
|
||||||
|
@ -134,6 +143,7 @@ dump_def (progs_t *pr, ddef_t *def, int indent)
|
||||||
case ev_type_count:
|
case ev_type_count:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
printf ("%*s %x %d %s %s%s\n", indent * 12, "",
|
printf ("%*s %x %d %s %s%s\n", indent * 12, "",
|
||||||
offset, saveglobal, name, type, comment);
|
offset, saveglobal, name, type, comment);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue