less: Fix memory leak when scrolling to EOF

This commit is contained in:
Rummskartoffel 2022-01-24 21:30:06 +01:00 committed by Brian Gianforcaro
parent fa3c61cf5a
commit f3341f48e3
Notes: sideshowbarker 2024-07-17 20:17:07 +09:00

View File

@ -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;
}