From 545d8277747af1888486cf920eabb327f41bd3f3 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 30 Jul 2025 11:22:57 +0200 Subject: [PATCH] #12654 Las import: fix crash for files with CR/LF on linux The file in question had a "empty" line with CR/LF line ending at the end of the file. When reading this on linux (using getline) you get a non-empty string containing the CR token. For these cases GetRecord returns true with a empty record vector, and this expected in the calling code. Crash happens when accessing the first (non-existing) element of the empty vector when trying to provide error message. Fixed by having GetRecord return false when vector is empty. Fixes #12654. --- ThirdParty/NRLib/nrlib/well/laswell.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/NRLib/nrlib/well/laswell.cpp b/ThirdParty/NRLib/nrlib/well/laswell.cpp index efb283fc3d..bc70ba37f5 100644 --- a/ThirdParty/NRLib/nrlib/well/laswell.cpp +++ b/ThirdParty/NRLib/nrlib/well/laswell.cpp @@ -439,7 +439,7 @@ LasWell::GetRecord(std:: ifstream & fin, record.insert(record.end(), items.begin(), items.end()); } } - return(true); + return(!record.empty()); } void LasWell::AddLog(const std::string & name,