Commit 9c38c070085b566e2fc3f7696cdd4362c2759285

Authored by Stephen Warren
Committed by Simon Glass
1 parent 4d907025d6

sandbox: terminate os_dirent_ls() result list

Each node in the linked-list that os_dirent_ls() returns has its next
pointer set only when the next node is created. For the last node in the
list, there is no next node, so this never happens, and the next pointer
is never initialized. Explicitly initialize the next pointer so that it
isn't dangling. Without this, "sb ls" might crash.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>

Showing 1 changed file with 1 additions and 0 deletions Side-by-side Diff

arch/sandbox/cpu/os.c
... ... @@ -341,6 +341,7 @@
341 341 ret = -ENOMEM;
342 342 goto done;
343 343 }
  344 + next->next = NULL;
344 345 strcpy(next->name, entry.d_name);
345 346 switch (entry.d_type) {
346 347 case DT_REG: