]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix minor NULL check in DataMap_Copy function.
authorOliver Kurth <okurth@vmware.com>
Mon, 28 Oct 2019 23:12:39 +0000 (16:12 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 28 Oct 2019 23:12:39 +0000 (16:12 -0700)
One of the code scanners identified the following issue in
DataMap_Copy function.

"""
Either the condition 'src==NULL' is redundant or there is possible null pointer dereference: src.
"""

Fixed the issue by moving the NULL check to the top of the function.

open-vm-tools/lib/dataMap/dataMap.c

index b76abcd534d91dc1e7bb7aaaca185da58e187a13..067cfe05e5b3928b5835672cb10d33c1a04fb007 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2012-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2012-2017,2019 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -1719,13 +1719,13 @@ DataMap_Copy(const DataMap *src,  // IN
    ClientData clientData;
    ErrorCode res;
 
-   ASSERT(src->map != NULL);
-   ASSERT(src->cookie == magic_cookie);
-
    if (src == NULL || dst == NULL) {
       return  DMERR_INVALID_ARGS;
    }
 
+   ASSERT(src->map != NULL);
+   ASSERT(src->cookie == magic_cookie);
+
    /* init dst map */
    res = DataMap_Create(dst);
    if (res != DMERR_SUCCESS) {