On Thu, 30 Jan 2025 16:42:43 +0300, Anton Moryakov wrote: > Report of the static analyzer: > 1. NULL_AFTER_DEREF Pointer 'str', which is dereferenced at image-host.c:688 > by calling function 'strdup', is compared to a NULL value at image-host.c:691. > 2. NULL_AFTER_DEREF Pointer 'list', which is dereferenced at > image-host.c:689, is compared to a NULL value at image-host.c:691. > > Corrections explained: > 1. Checking for NULL before using pointers: The if (!list || !str) check is > now performed before calling strdup and realloc, which prevents null pointer > dereferences. > 2. Checking the result of strdup: strdup can return NULL if memory allocation > fails. This also needs to be checked. > 3. Checking the result of realloc: If realloc returns NULL, then memory has > not been allocated and dup must be freed to avoid memory leaks. > > [...]
Applied to u-boot/next, thanks! -- Tom