-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential crash with non-integer array size #585
Comments
ehaas
added
bug
Something isn't working
crash
A bug that causes the compiler to crash
labels
Nov 27, 2023
Fixed by something like: diff --git a/src/aro/Parser.zig b/src/aro/Parser.zig
index ebaa318..3b84321 100644
--- a/src/aro/Parser.zig
+++ b/src/aro/Parser.zig
@@ -2980,6 +2980,7 @@ fn directDeclarator(p: *Parser, base_type: Type, d: *Declarator, kind: Declarato
if (max_bits > 61) max_bits = 61;
const max_bytes = (@as(u64, 1) << @truncate(max_bits)) - 1;
+ if (size.ty.is(.invalid)) return Type.invalid;
if (!size.ty.isInt()) {
try p.errStr(.array_size_non_int, size_tok, try p.typeStr(size.ty));
return error.ParsingFailed; |
Here's an alternate path to trigger it: struct Foo {
int a;
} a;
char *f(char *arg) {
return arg + a?a;
} Do you think we should check in the typeStr functions? I'm guessing any place we call that could potentially have an invalid type |
That would solve the issue but it'd be nicer to properly handle |
ehaas
added a commit
to ehaas/arocc
that referenced
this issue
Dec 14, 2023
Closes Vexu#585 Co-authored-by: Veikka Tuominen <git@vexu.eu>
ehaas
added a commit
to ehaas/arocc
that referenced
this issue
Dec 15, 2023
Closes Vexu#585 Co-authored-by: Veikka Tuominen <git@vexu.eu>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Strange one found via fuzzing. If the array size specifier is
.invalid
:The text was updated successfully, but these errors were encountered: