From: Kruti Pendharkar Date: Tue, 22 Jul 2025 07:06:54 +0000 (-0700) Subject: Change to common source file not applicable to open-vm-tools. X-Git-Tag: stable-13.1.0~120 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=44e464d4012ec2cefc1e82f82e23d9481cb784a7;p=thirdparty%2Fopen-vm-tools.git Change to common source file not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/misc/dynbuf.c b/open-vm-tools/lib/misc/dynbuf.c index 91b87f453..ccb30522d 100644 --- a/open-vm-tools/lib/misc/dynbuf.c +++ b/open-vm-tools/lib/misc/dynbuf.c @@ -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;