From 413f274f20bd7e614e144b512b38984d1e9f28b3 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 10 Feb 2010 11:29:58 -0800 Subject: [PATCH] dhcp: Don't pass NULL to memcmp() even with size 0. ISO C says that the arguments to memcmp() must be nonnull even if the size argument is 0, so don't do that. Found by Clang (http://clang-analyzer.llvm.org). --- lib/dhcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dhcp.c b/lib/dhcp.c index f0c36442..51d6ed07 100644 --- a/lib/dhcp.c +++ b/lib/dhcp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Nicira Networks. + * Copyright (c) 2008, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -497,7 +497,7 @@ dhcp_option_equals(const struct dhcp_option *a, const struct dhcp_option *b) { return ((a->data != NULL) == (b->data != NULL) && a->n == b->n - && !memcmp(a->data, b->data, a->n)); + && (!a->data || !memcmp(a->data, b->data, a->n))); } /* Replaces 'ds' by a string representation of 'msg'. If 'multiline' is -- 2.30.2