Really fix segfault in 2001/bellard.otccex.c

The segfault fix (that prevented it from working at all) that I made a
while back was not actually complete. It should work fine now (famous
last words but it does appear to work now with different values where it
crashed). Some ints were used as pointers (including a function
pointer).

It should be noted again that 2000/bellard itself does not work but
having this program bug fixed will be helpful for anyone who might want
a crack at fixing bellard.c (see bugs.md).
This commit is contained in:
Cody Boone Ferguson committed 2023-04-20 13:41:57 -07:00
1 parent bee1d82370
commit 85842bfc7c
1 file changed
+4 -4
+4 -4
View File
@@ -44,7 +44,7 @@ fact(n)
/* Well, we could use printf, but it would be too easy */
print_num(n, b)
{
int tab, p, c;
int *tab, *p, c;
/* Numbers can be entered in decimal, hexadecimal ('0x' prefix) and
octal ('0' prefix) */
/* more complex programs use malloc */
@@ -57,7 +57,7 @@ print_num(n, b)
c = c + 'a' - 10;
else
c = c + '0';
*(char *)p = c;
*p = c;
p++;
n = n / b;
/* 'break' is supported */
@@ -66,7 +66,7 @@ print_num(n, b)
}
while (p != tab) {
p--;
printf("%c", *(char *)p);
printf("%c", *p);
}
free(tab);
}
@@ -78,7 +78,7 @@ main(int argc, char **argv)
supported. As long as you do not use a globally defined
variable name as local variable (which is a bad habbit), you
won't have any problem */
int n, f, base;
int n, (*f)(), base;
/* && and || operator have the same semantics as C (left to right
evaluation and early exit) */