mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Simplify tokens_owner cleanup in read_from_stream per review
Drop the justification comment and the manual reset/nullptr pair; letting the unique_ptr go out of scope at function exit already frees the lexer on every return path. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -1584,10 +1584,6 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Owned via RAII so that any early return or exception while scanning
|
|
||||||
// the file (e.g. a malformed header, see fuzzer-z6u) still frees the
|
|
||||||
// lexer instead of leaking it; `tokens` itself stays a raw pointer since
|
|
||||||
// it's read by in_memory_file_storage::load() during the scan below.
|
|
||||||
std::unique_ptr<IfcSpfLexer> tokens_owner(new IfcSpfLexer(s, logger()));
|
std::unique_ptr<IfcSpfLexer> tokens_owner(new IfcSpfLexer(s, logger()));
|
||||||
tokens = tokens_owner.get();
|
tokens = tokens_owner.get();
|
||||||
|
|
||||||
@@ -1694,9 +1690,6 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
|||||||
|
|
||||||
logger().Status("\rDone scanning file ");
|
logger().Status("\rDone scanning file ");
|
||||||
|
|
||||||
tokens_owner.reset();
|
|
||||||
tokens = nullptr;
|
|
||||||
|
|
||||||
if (good_ != file_open_status::SUCCESS) {
|
if (good_ != file_open_status::SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user