Skip to content

Commit aa0171d

Browse files
[OpenCL-AOT] Fix out of range issue of finding file extension (#11767)
Co-authored-by: Alexey Sachkov <[email protected]>
1 parent c39c213 commit aa0171d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

opencl/opencl-aot/source/utils.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,10 @@ readBinaryFile(std::string FileName) {
405405

406406
bool isFileEndsWithGivenExtentionName(const std::string &FileName,
407407
const char *Ext) {
408-
return FileName.substr(FileName.find_last_of('.')) == Ext;
408+
std::size_t LastCharPosition = FileName.find_last_of('.');
409+
if (LastCharPosition == std::string::npos)
410+
return false;
411+
return FileName.substr(LastCharPosition) == Ext;
409412
}
410413

411414
bool isFileStartsWithGivenMagicNumber(const std::vector<char> &BinaryData,

0 commit comments

Comments
 (0)