mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
less: Fix memory leak when scrolling to EOF
This commit is contained in:
parent
fa3c61cf5a
commit
f3341f48e3
1 changed files with 3 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue