The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/misc: Only free memory if there was an allocation error

+6 -2
+6 -2
src/xrt/auxiliary/util/u_misc.h
··· 1 - // Copyright 2019, Collabora, Ltd. 1 + // Copyright 2019-2023, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file ··· 89 89 u_realloc_or_free(void *ptr, size_t new_size) 90 90 { 91 91 void *ret = realloc(ptr, new_size); 92 - if (ret == NULL) { 92 + if (ret == NULL && new_size != 0) { 93 + /* 94 + * We only need to call free if the new size isn't zero, and 95 + * that realloc failed to allocate a new array. 96 + */ 93 97 free(ptr); 94 98 } 95 99 return ret;