Skip to content

Commit

Permalink
Bug 1873131 - Add some assertions to UniqueFileHandle. r=nika,tsmith
Browse files Browse the repository at this point in the history
  • Loading branch information
jld committed Jan 6, 2024
1 parent 39cc886 commit 7cb8ed1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mfbt/UniquePtrExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <type_traits>

#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/fallible.h"
Expand Down Expand Up @@ -103,7 +104,11 @@ typedef int FileHandleType;
#endif

struct FileHandleHelper {
MOZ_IMPLICIT FileHandleHelper(FileHandleType aHandle) : mHandle(aHandle) {}
MOZ_IMPLICIT FileHandleHelper(FileHandleType aHandle) : mHandle(aHandle) {
#if defined(XP_UNIX) && (defined(DEBUG) || defined(FUZZING))
MOZ_RELEASE_ASSERT(aHandle == kInvalidHandle || aHandle > 2);
#endif
}

MOZ_IMPLICIT constexpr FileHandleHelper(std::nullptr_t)
: mHandle(kInvalidHandle) {}
Expand Down

0 comments on commit 7cb8ed1

Please sign in to comment.