From 001e157a7b43a4f40219ddbadc7870ed1b43d8da Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 18 Nov 2021 16:47:00 -0500 Subject: [PATCH] libroot_build: Add better error checking to _kern_dup. This way, we will get a more coherent crash instead of an unceremonious one. Follow-up to #17389. Change-Id: Iffbf421ce85d638628243d5785ba61ff6b9a8043 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4729 Reviewed-by: waddlesplash --- src/build/libroot/fs.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/build/libroot/fs.cpp b/src/build/libroot/fs.cpp index 268954fc7b..149c8c054f 100644 --- a/src/build/libroot/fs.cpp +++ b/src/build/libroot/fs.cpp @@ -117,7 +117,7 @@ utimes_helper(File& file, const struct timespec times[2]) timeBuffer[1] = now; } - return file.SetTimes(timeBuffer); + return file.SetTimes(timeBuffer); } #endif // _HAIKU_BUILD_NO_FUTIMENS || _HAIKU_BUILD_NO_FUTIMENS @@ -811,10 +811,12 @@ _kern_dup(int fd) return B_FILE_ERROR; // clone it - Descriptor *clone; + Descriptor *clone = NULL; status_t error = descriptor->Dup(clone); if (error != B_OK) return error; + if (clone == NULL) + debugger("Dup() succeeded but descriptor is NULL"); return add_descriptor(clone); }