History

libtcc test: output type has to be set before loading libraries

Libtcc does a different thing on dynamic libraries based on the output type and it will crash in plenty of cases since the initial type is set to 0 (not 1 which TCC_OUTPUT_MEMORY is).

Sigrid Solveig Haflínudóttir committed 10 months ago

Commit 0074d9e1 parent f829c301 file · +3 −3Browse files

Unified · Split

tests/libtcc_test.c+3−3
@@ -60,6 +60,9 @@ int main(int argc, char **argv) · 59 unmodified lines
6060 /* set custom error/warning printer */
6161 tcc_set_error_func(s, stderr, handle_error);
6262
63+ /* MUST BE CALLED before any compilation */
64+ tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
65+
6366 /* if tcclib.h and libtcc1.a are not installed, where can we find them */
6467 for (i = 1; i < argc; ++i) {
6568 char *a = argv[i];
@@ -73,9 +76,6 @@ int main(int argc, char **argv) · 7 unmodified lines
7376 }
7477 }
7578
76− /* MUST BE CALLED before any compilation */
77− tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
78−
7979 if (tcc_compile_string(s, my_program) == -1)
8080 return 1;
8181

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t