From: Ben Pfaff <blp@nicira.com>
Date: Wed, 10 Feb 2010 19:29:58 +0000 (-0800)
Subject: dhcp: Don't pass NULL to memcmp() even with size 0.
X-Git-Tag: v1.0.0~259^2~157
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=413f274f20bd7e614e144b512b38984d1e9f28b3;p=sliver-openvswitch.git

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

diff --git a/lib/dhcp.c b/lib/dhcp.c
index f0c36442d..51d6ed070 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