|
From: | Pascal Cuoq |
Subject: | [Tinycc-devel] missing check after calling type_size in classify_x86_64_arg |
Date: | Thu, 20 Jun 2019 08:26:55 +0000 |
Hello,
the function type_size can fail and return -1 for an incomplete enum:
In this case it leaves *a untouched.
When this happens when called from the function classify_x86_64_arg, it leads to using the automatic variable align uninitialized:
This scenario happens for some inputs files. I expect all inputs files that cause this to be invalid C programs, but a compiler that emits an error on invalid inputs is better than a compiler that displays undefined behavior on invalid inputs.
An example of an input file causing execution to go through classify_x86_64_arg with type_size returning -1 is the following:
enum t f(int x) {
while(1);
}
I was thinking of inserting a check like “if (size < 0) tcc_error("incomplete enum");” after the call to type_size in classify_x86_64_arg.
The function type_size is called from a lot of places so I didn't even consider making it abort directly instead, but if someone suggests it might be better I can look into it.
Pascal
|
[Prev in Thread] | Current Thread | [Next in Thread] |