mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-01 04:30:29 +01:00
systemd/tests: avoid using g_free() with buffers allocated with malloc() in _test_unbase64mem_mem()
Coverity says: Error: ALLOC_FREE_MISMATCH (CWE-762): NetworkManager-1.31.3/src/core/tests/test-systemd.c:261: alloc: Allocation of memory which must be freed using "free". NetworkManager-1.31.3/src/core/tests/test-systemd.c:274: free: Calling "_nm_auto_g_free" frees "exp2_arr" using "g_free" but it should have been freed using "free". # 272| g_assert_cmpmem(expected_arr, expected_len, exp3_arr, exp3_len); # 273| } # 274|-> } # 275| # 276| #define _test_unbase64mem(base64, expected_str) \ Error: ALLOC_FREE_MISMATCH (CWE-762): NetworkManager-1.31.3/src/core/tests/test-systemd.c:270: alloc: Allocation of memory which must be freed using "free". NetworkManager-1.31.3/src/core/tests/test-systemd.c:274: free: Calling "_nm_auto_g_free" frees "exp3_arr" using "g_free" but it should have been freed using "free". # 272| g_assert_cmpmem(expected_arr, expected_len, exp3_arr, exp3_len); # 273| } # 274|-> } # 275| # 276| #define _test_unbase64mem(base64, expected_str) \ Fixes:0298d54078('systemd: expose unbase64mem() as nm_sd_utils_unbase64mem()') (cherry picked from commit44abe6d661) (cherry picked from commitd2d343289d)
This commit is contained in:
parent
023c6a66d9
commit
76ef3efdff
1 changed files with 5 additions and 5 deletions
|
|
@ -247,11 +247,11 @@ _test_unbase64mem_mem(const char *base64, const guint8 *expected_arr, gsize expe
|
|||
{
|
||||
gs_free char *expected_base64 = NULL;
|
||||
int r;
|
||||
gs_free guint8 *exp2_arr = NULL;
|
||||
gs_free guint8 *exp3_arr = NULL;
|
||||
gsize exp2_len;
|
||||
gsize exp3_len;
|
||||
gsize i;
|
||||
nm_auto_free guint8 *exp2_arr = NULL;
|
||||
nm_auto_free guint8 *exp3_arr = NULL;
|
||||
gsize exp2_len;
|
||||
gsize exp3_len;
|
||||
gsize i;
|
||||
|
||||
expected_base64 = g_base64_encode(expected_arr, expected_len);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue