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 <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-03-02 13:37:11 +02:00
parent 2efdbde276
commit bd27b1360f

View file

@ -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)