Skip to content

Commit 0bda000

Browse files
vonosmasAlexey Samsonov
andauthored
Fix UB in MallocBench/gs/interp.c (#234)
It is undefined behaviour to construct a pointer that is out-of-bounds, not just to use it. This is a follow-up to commit 9391cd9 which fixed the same problem (detected by -fsanitize=array-bounds) in MallocBench/cfrac. Co-authored-by: Alexey Samsonov <[email protected]>
1 parent 0bbf038 commit 0bda000

File tree

1 file changed

+2
-2
lines changed
  • MultiSource/Benchmarks/MallocBench/gs

1 file changed

+2
-2
lines changed

MultiSource/Benchmarks/MallocBench/gs/interp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private op_proc_(interp_exit);
4747
#define os_guard_under 10
4848
#define os_guard_over 10
4949
private ref ostack[os_guard_under+max_ostack+os_guard_over];
50-
ref estack[max_estack];
50+
ref estack[max_estack + 1];
5151
ref dstack[max_dstack];
5252
ref *osp_nargs[os_max_nargs]; /* for checking osp */
5353

@@ -107,7 +107,7 @@ interp_init(int ndict)
107107
for ( i = 1; i < os_max_nargs; i++ )
108108
osp_nargs[i] = osbot + i - 1;
109109
}
110-
esp = estack - 1, estop = estack + (max_estack-1);
110+
esp = estack, estop = estack + max_estack;
111111
/* Initialize the dictionary stack to the first ndict */
112112
/* dictionaries. ndict is a parameter because during */
113113
/* initialization, only systemdict exists. */

0 commit comments

Comments
 (0)