Skip to content

Commit

Permalink
GH-61 Place an upper bound on p4StackDump().
Browse files Browse the repository at this point in the history
  • Loading branch information
SirWumpus committed Nov 7, 2024
1 parent c2de43f commit 5b85ce7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/post4.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,18 @@ p4Nap(P4_Uint seconds, P4_Uint nanoseconds)
}

void
p4StackDump(FILE *fp, P4_Cell *base, P4_Uint length)
p4StackDump(FILE *fp, P4_Cell *base, unsigned length)
{
P4_Cell *cell;
unsigned count;

/* Place an upper bounds on the length of the stack
* to handle a converted signed value or impossibly
* large value being given.
*/
if (1024 <= length) {
length = 1024;
}
for (count = 0, cell = base; 0 < length--; cell++) {
if ((count & 3) == 0) {
(void) fprintf(fp, "top-%.2u ", (unsigned) length);
Expand Down
2 changes: 1 addition & 1 deletion src/post4.p4
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ MAX-U MAX-N 2CONSTANT MAX-D
\ (C: <spaces>name -- ) (S: -- xt )
: ['] LIT LIT COMPILE, ' COMPILE, ; IMMEDIATE compile-only

\ (C: x -- ) (S: x -- )
\ (C: x -- ; S: -- x )
: LIT, ['] LIT COMPILE, , ;

\ ... : name ... [ x ] LITERAL ... ;
Expand Down

0 comments on commit 5b85ce7

Please sign in to comment.