memcpy() should not receive NULL as source pointer and such is passed
from test_snep_read_get_req_frags_client_resp() and
test_snep_read_verify_resp(). ASAN reports:
unit/test-snep-read.c:325:2: runtime error: null pointer passed as argument 2, which
is declared to never be null
unit/test-snep-read.c:266:2: runtime error: null pointer passed as argument 2, which
is declared to never be null
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski(a)canonical.com>
---
unit/test-snep-read.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/unit/test-snep-read.c b/unit/test-snep-read.c
index 128937ed910f..ea41ae03a8b2 100644
--- a/unit/test-snep-read.c
+++ b/unit/test-snep-read.c
@@ -261,7 +261,8 @@ static struct p2p_snep_req_frame *test_snep_build_req_frame(
req->version = ver;
req->request = req_type;
req->length = GUINT_TO_BE(info_len);
- memcpy(req->ndef, data, payload_len);
+ if (data)
+ memcpy(req->ndef, data, payload_len);
return req;
}
@@ -320,7 +321,8 @@ static struct p2p_snep_resp_frame *test_snep_build_resp_frame(
resp->version = ver;
resp->response = resp_type;
resp->length = GUINT_TO_BE(info_len);
- memcpy(resp->info, data, info_len);
+ if (data)
+ memcpy(resp->info, data, info_len);
return resp;
}
--
2.27.0