diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-09-01 00:41:32 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-01 18:06:14 +0200 |
commit | 0bd089b28295918ce07318d5de473101f97a7549 (patch) | |
tree | e3a79dae1cb7cab66ff25e68de444edf24efcf24 /Userland | |
parent | afa0fb55b01b3da9a1733cd82915c425d8e92c85 (diff) | |
download | serenity-0bd089b28295918ce07318d5de473101f97a7549.zip |
SoundPlayer: Fix file leak in M3UParser::from_file(..)
Found by Sonar Cloud.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/SoundPlayer/M3UParser.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Userland/Applications/SoundPlayer/M3UParser.cpp b/Userland/Applications/SoundPlayer/M3UParser.cpp index 9efb030168..19e3dd5cbc 100644 --- a/Userland/Applications/SoundPlayer/M3UParser.cpp +++ b/Userland/Applications/SoundPlayer/M3UParser.cpp @@ -7,6 +7,7 @@ #include "M3UParser.h" #include <AK/OwnPtr.h> #include <AK/RefPtr.h> +#include <AK/ScopeGuard.h> #include <AK/Utf8View.h> M3UParser::M3UParser() @@ -19,6 +20,7 @@ NonnullOwnPtr<M3UParser> M3UParser::from_file(const String path) VERIFY(!path.is_null() && !path.is_empty() && !path.is_whitespace()); parser->m_use_utf8 = path.ends_with(".m3u8", AK::CaseSensitivity::CaseInsensitive); FILE* file = fopen(path.characters(), "r"); + ScopeGuard file_guard = [&] { fclose(file); }; VERIFY(file != nullptr); fseek(file, 0, SEEK_END); size_t file_size = ftell(file); |