Skip to content

Commit

Permalink
Fix UBSan issue (#1615)
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitri Mokhov <[email protected]>
  • Loading branch information
dnmokhov authored Jan 28, 2025
1 parent 9d45787 commit 3c85ad7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions include/oneapi/tbb/concurrent_hash_map.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2022 Intel Corporation
Copyright (c) 2005-2025 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -467,9 +467,13 @@ class hash_map_iterator {
friend class concurrent_hash_map;

hash_map_iterator( const Container &map, std::size_t index, const bucket *b, node_base *n ) :
my_map(&map), my_index(index), my_bucket(b), my_node(static_cast<node*>(n))
my_map(&map), my_index(index), my_bucket(b), my_node(nullptr)
{
if( b && !map_base::is_valid(n) )
// Cannot directly initialize to n, because it could be an invalid node pointer (e.g., when
// setting a midpoint for a 1-element range). If it is, try one from a subsequent bucket.
if( map_base::is_valid(n) )
my_node = static_cast<node*>(n);
else if( b )
advance_to_next_bucket();
}

Expand Down

0 comments on commit 3c85ad7

Please sign in to comment.