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 <[email protected]>
This commit is contained in:
Augustin Cavalier
2021-11-23 17:24:46 +00:00
committed by waddlesplash
parent 23888052c9
commit 001e157a7b
+4 -2
View File
@@ -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);
}