Skip to content

Commit f1138e8

Browse files
committed
Avoid undefined behavior by ensuring m_path is not empty
Debug version crashes here, release version optimizes away the check.
1 parent 90f0acf commit f1138e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/xtensor-zarr/xzarr_node.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace xt
6868
{
6969
m_path = '/' + m_path;
7070
}
71-
while (m_path.back() == '/')
71+
while (!m_path.empty() && m_path.back() == '/')
7272
{
7373
m_path = m_path.substr(0, m_path.size() - 1);
7474
}

0 commit comments

Comments
 (0)