ref: 74e9de1b71c0fd30899c48e0bdddcbb66482f17c
parent: 015d2b08303df03e81081a7627a2ac48fd7b812d
author: dbrotz <43593771+dbrotz@users.noreply.github.com>
date: Tue Jun 11 06:45:51 EDT 2019
Check for RPN stack overflow in linker
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -18,13 +18,18 @@
#include "link/mylink.h"
#include "link/symbol.h"
+#define RPN_STACK_SIZE 256
+
static struct sSection *pCurrentSection;
-static int32_t rpnstack[256];
+static int32_t rpnstack[RPN_STACK_SIZE];
static int32_t rpnp;
int32_t nPC;
static void rpnpush(int32_t i)
{
+ if (rpnp >= RPN_STACK_SIZE)
+ errx(1, "RPN stack overflow");
+
rpnstack[rpnp] = i;
rpnp++;
}