From bd27b1360f3dba633bfee19f230226b02d2f0f78 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 2 Mar 2014 13:37:11 +0200 Subject: [PATCH] Make code path easier for static analyzers record->type == NULL case was handled through the record->type_length comparison. While this was correct, it is a bit difficult for static analyzers to understand, so add an extra check for NULL to avoid false reports on this. Signed-off-by: Jouni Malinen --- src/wps/ndef.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wps/ndef.c b/src/wps/ndef.c index 2b3506476..d45dfc8ef 100644 --- a/src/wps/ndef.c +++ b/src/wps/ndef.c @@ -148,7 +148,8 @@ static struct wpabuf * ndef_build_record(u8 flags, void *type, static int wifi_filter(struct ndef_record *record) { - if (record->type_length != os_strlen(wifi_handover_type)) + if (record->type == NULL || + record->type_length != os_strlen(wifi_handover_type)) return 0; if (os_memcmp(record->type, wifi_handover_type, os_strlen(wifi_handover_type)) != 0) @@ -173,7 +174,8 @@ struct wpabuf * ndef_build_wifi(const struct wpabuf *buf) static int p2p_filter(struct ndef_record *record) { - if (record->type_length != os_strlen(p2p_handover_type)) + if (record->type == NULL || + record->type_length != os_strlen(p2p_handover_type)) return 0; if (os_memcmp(record->type, p2p_handover_type, os_strlen(p2p_handover_type)) != 0)