-
Marco Trevisan authored
In case data is NULL we ended up to call memcpy with NULL parameter which is undefined behavior (see the trace below). So instead of having multiple null checks to do just the same, simplify the NULL or 0-sized cases. ../glib/gbytes.c:140:7: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x7f56ea7c667e in g_bytes_new ../glib/gbytes.c:140 #1 0x5557c3659f06 in test_null ../glib/tests/bytes.c:453 #2 0x7f56ea9c0f70 in test_case_run ../glib/gtestutils.c:3115 #3 0x7f56ea9c0f70 in g_test_run_suite_internal ../glib/gtestutils.c:3210 #4 0x7f56ea9c0ceb in g_test_run_suite_internal ../glib/gtestutils.c:3229 #5 0x7f56ea9c1f89 in g_test_run_suite ../glib/gtestutils.c:3310 #6 0x7f56ea9c20df in g_test_run ../glib/gtestutils.c:2379 #7 0x5557c36599d2 in main ../glib/tests/bytes.c:536
Marco Trevisan authoredIn case data is NULL we ended up to call memcpy with NULL parameter which is undefined behavior (see the trace below). So instead of having multiple null checks to do just the same, simplify the NULL or 0-sized cases. ../glib/gbytes.c:140:7: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x7f56ea7c667e in g_bytes_new ../glib/gbytes.c:140 #1 0x5557c3659f06 in test_null ../glib/tests/bytes.c:453 #2 0x7f56ea9c0f70 in test_case_run ../glib/gtestutils.c:3115 #3 0x7f56ea9c0f70 in g_test_run_suite_internal ../glib/gtestutils.c:3210 #4 0x7f56ea9c0ceb in g_test_run_suite_internal ../glib/gtestutils.c:3229 #5 0x7f56ea9c1f89 in g_test_run_suite ../glib/gtestutils.c:3310 #6 0x7f56ea9c20df in g_test_run ../glib/gtestutils.c:2379 #7 0x5557c36599d2 in main ../glib/tests/bytes.c:536
Loading