]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Change to common source file not applicable to open-vm-tools.
authorKruti Pendharkar <kp025370@broadcom.com>
Tue, 22 Jul 2025 07:06:54 +0000 (00:06 -0700)
committerKruti Pendharkar <kp025370@broadcom.com>
Tue, 22 Jul 2025 07:06:54 +0000 (00:06 -0700)
open-vm-tools/lib/misc/dynbuf.c

index 91b87f4532d8618edf5461b0a11de1c7ecfb3ac9..ccb30522d6a6807f00019e7a52017f2f79091f9d 100644 (file)
@@ -1,5 +1,6 @@
 /*********************************************************
- * Copyright (C) 1998-2022 VMware, Inc. All rights reserved.
+ * Copyright (c) 1998-2025 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
  *
  * 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
@@ -261,10 +262,16 @@ DynBufRealloc(DynBuf *b,            // IN/OUT:
 
    ASSERT(b);
 
-   new_data = realloc(b->data, newAllocated);
-   if (new_data == NULL && newAllocated) {
-      /* Not enough memory */
-      return FALSE;
+   if (newAllocated == 0) {
+      /* In C23, realloc with size 0 is undefined. */
+      free(b->data);
+      new_data = NULL;
+   } else {
+      new_data = realloc(b->data, newAllocated);
+      if (new_data == NULL) {
+         /* Not enough memory */
+         return FALSE;
+      }
    }
 
    b->data = new_data;