Skip to content

Commit 148185e

Browse files
committed
Change to early exit
Signed-off-by: James Brodman <[email protected]>
1 parent c06721c commit 148185e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sycl/include/CL/sycl/detail/aligned_allocator.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ template <typename T> class aligned_allocator {
5353
pointer allocate(size_t Size) {
5454
size_t NumBytes = Size * sizeof(value_type);
5555
NumBytes = ((NumBytes - 1) | (MAlignment - 1)) + 1;
56+
if (0 == NumBytes)
57+
throw std::bad_alloc();
5658

5759
pointer Result = reinterpret_cast<pointer>(
5860
detail::OSUtil::alignedAlloc(MAlignment, NumBytes));
59-
if (!Result || NumBytes == 0)
61+
if (!Result)
6062
throw std::bad_alloc();
6163
return Result;
6264
}

0 commit comments

Comments
 (0)