Report proper error message for negative global array values. Thank you melg8

This commit is contained in:
Jeremiah Orians 2021-06-26 10:53:45 -04:00
parent 3bac25a1ac
commit b37dfc7b12
No known key found for this signature in database
GPG Key ID: 6B3A3F198708F894
3 changed files with 15 additions and 7 deletions

View File

@ -1918,6 +1918,14 @@ new_type:
require(NULL != global_token->next->next, "Unterminated global\n");
global_token = global_token->next->next;
/* Make sure not negative */
if(match("-", global_token->s))
{
line_error();
fputs("Negative values are not supported\n", stderr);
exit(EXIT_FAILURE);
}
/* length */
size = strtoint(global_token->s);
@ -1927,7 +1935,7 @@ new_type:
require_match("missing ;\n", ";");
/* Stop bad states */
require(size > 0, "Negative values are not supported\n");
require(size > 0, "M2-Planet is very inefficient so you probably don't want to allocate 4+K bytes into your binary for NULLs\n");
require(size < 4096, "M2-Planet is very inefficient so you probably don't want to allocate 4+K bytes into your binary for NULLs\n");
globals_list = emit("\n'", globals_list);
while (0 != size)

View File

@ -179,8 +179,8 @@ fc31fc8b2d78bd50a4c89eb0e29149626868a70842a3dcb01ea87bb275a9e3c2 test/results/t
965bdf7049179199b9f423250a186c7b64ea55326c3249127d2daf7d42ae53cc test/results/test0106-knight-native-binary
0a929d6990caee3e93b1188a38fd3041c6f8e46d25a386024647c0f05c33bce7 test/results/test0106-knight-posix-binary
331ffb5284bd824494ad61a3b0b2dff5681a63ab604e9a06100af531ae237148 test/results/test0106-x86-binary
bf4f7f9d67f2ea52dafd6ff7f1052e24c97a2cfbf6fb61dc7611203638915314 test/results/test1000-aarch64-binary
5c123b5e4812afce97f88349a50385f20b3841f8db5dcf83b951efb6b818da48 test/results/test1000-amd64-binary
b85feeaee87ddf3c668ecd920dbea0419393f5f982035a486729b588701d4c4f test/results/test1000-armv7l-binary
ee9c19a5dcaf7df08751854f14a6865621377070283f20a1e83b818dce5e2f92 test/results/test1000-knight-posix-binary
92df1f4df13ce765f2bf2438db64f778fc9d62ae72d85974b226fcacebe87a90 test/results/test1000-x86-binary
1ff4ad6d281cef057c9ee403ca459561d74b16a9964b98a00609b1d36ed7da2f test/results/test1000-aarch64-binary
c7d10909fe88c8b88fcf19fad2c3a5e98c59b36184a7e5167a28e5081902f79c test/results/test1000-amd64-binary
5d1724931335c9727fb230d1baf2249b4ec0dc7b0d98f8557cb4558850f2f74a test/results/test1000-armv7l-binary
23cc0ddbdaadca447df35bb19a281c9de64e2a08a4c9ab279725c64788d6432e test/results/test1000-knight-posix-binary
71759bae8a9fbdc28c3e0242fa52f9556cec40d075b749c90759cfe8a35d1624 test/results/test1000-x86-binary

View File

@ -1 +1 @@
53c80ac4d9c0b8d7f032efd604fad349a9cd57f1e5fc4529cbf8fc8f24f1d25e test/test1000/proof
9f376d7d2d6d04aa15bdbaa92a3dc48886323ff73de6509da6fc0a9beb9eb6d8 test/test1000/proof