From 554448a1f1c1e5daf72193c9609bf1112fc43ce9 Mon Sep 17 00:00:00 2001 From: Greg King Date: Sat, 20 Oct 2018 13:40:16 -0400 Subject: [PATCH] .byt "" emits no data; avoid a ca65 crash. Fixes #775 on GitHub. --- src/ca65/pseudo.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index 5dd67af90..a1115606b 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -574,7 +574,7 @@ static void DoByte (void) /* Record type information */ Span* S = OpenSpan (); - StrBuf Type = STATIC_STRBUF_INITIALIZER; + StrBuf Type = AUTO_STRBUF_INITIALIZER; /* Parse arguments */ while (1) { @@ -598,9 +598,14 @@ static void DoByte (void) } } - /* Close the span, then add type information to it */ + /* Close the span, then add type information to it. + ** Note: empty string operands emit nothing; + ** so, add a type only if there's a span. + */ S = CloseSpan (S); - SetSpanType (S, GenArrayType (&Type, GetSpanSize (S), EType, sizeof (EType))); + if (S != 0) { + SetSpanType (S, GenArrayType (&Type, GetSpanSize (S), EType, sizeof (EType))); + } /* Free the type string */ SB_Done (&Type);