ref: c7fe281c86430cb125acbf1916b92131898eef5d
parent: fa8f25a4de2f81665379ad0896a11b5148b02012
parent: 951c9b66f40592d26fc9cd9f97b05af3a7cb711e
author: AntonioND <[email protected]>
date: Mon Feb 27 16:09:04 EST 2017
Merge pull request #114 from Ben10do/fix-asm-tests Fix issues in rgbasm raised by the tests
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -142,8 +142,9 @@
{
SLONG level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer;
+ char *bufferEnd = pCurrentBuffer->pBufferStart + pCurrentBuffer->nBufferSize;
- while( *src && level )
+ while( src < bufferEnd && level )
{
if( instring==0 )
{
@@ -221,8 +222,9 @@
{
SLONG level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer;
+ char *bufferEnd = pCurrentBuffer->pBufferStart + pCurrentBuffer->nBufferSize;
- while( *src && level )
+ while( src < bufferEnd && level )
{
if( instring==0 )
{
--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -316,6 +316,9 @@
struct Expression * src2)
{
joinexpr();
+ if (src2->nVal == 0) {
+ fatalerror("division by zero");
+ }
expr->nVal = (expr->nVal / src2->nVal);
pushbyte(expr, RPN_DIV);
}
@@ -325,6 +328,9 @@
struct Expression * src2)
{
joinexpr();
+ if (src2->nVal == 0) {
+ fatalerror("division by zero");
+ }
expr->nVal = (expr->nVal % src2->nVal);
pushbyte(expr, RPN_MOD);
}