mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03:00
less: Fix memory leak when scrolling to EOF
This commit is contained in:
parent
fa3c61cf5a
commit
f3341f48e3
Notes:
sideshowbarker
2024-07-17 20:17:07 +09:00
Author: https://github.com/Rummskartoffel Commit: https://github.com/SerenityOS/serenity/commit/f3341f48e30 Pull-request: https://github.com/SerenityOS/serenity/pull/12117 Reviewed-by: https://github.com/bgianfo ✅
@ -287,6 +287,9 @@ public:
|
||||
char* line = nullptr;
|
||||
size_t n = 0;
|
||||
ssize_t size = getline(&line, &n, m_file);
|
||||
ScopeGuard guard([line] {
|
||||
free(line);
|
||||
});
|
||||
|
||||
if (size == -1)
|
||||
return false;
|
||||
@ -296,7 +299,6 @@ public:
|
||||
--size;
|
||||
|
||||
m_lines.append(String(line, size));
|
||||
free(line);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user