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
60 /* set custom error/warning printer */60 /* set custom error/warning printer */
61 tcc_set_error_func(s, stderr, handle_error);61 tcc_set_error_func(s, stderr, handle_error);
62 62
63 /* MUST BE CALLED before any compilation */
64 tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
65
63 /* if tcclib.h and libtcc1.a are not installed, where can we find them */66 /* if tcclib.h and libtcc1.a are not installed, where can we find them */
64 for (i = 1; i < argc; ++i) {67 for (i = 1; i < argc; ++i) {
65 char *a = argv[i];68 char *a = argv[i];
@@ -73,9 +76,6 @@ int main(int argc, char **argv) · 7 unmodified lines
73 }76 }
74 }77 }
75 78
76 /* MUST BE CALLED before any compilation */
77 tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
78
79 if (tcc_compile_string(s, my_program) == -1)79 if (tcc_compile_string(s, my_program) == -1)
80 return 1;80 return 1;
81 81

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