on xenial help sign in
Free resource in case of exceptions.
commitdcbcea205931e9b9fe4a31e5beefb4f8ae6192da authorJussi Pakkanen <jussi.pakkanen@canonical.com> dateWed 9 Oct 2013, 11:11 (13 years ago) parentb4ca0c4
1 file changed+6−2
plugins/Utils/albumartprovider.cpp+6−2
plugins/Utils/albumartprovider.cpp+6−2
@@ -176,8 +176,12 @@ std::string AlbumArtProvider::get_image(const std::string &artist, const std::st
176176 fread(buf, 1, s, f);
177177 fclose(f);
178178
179− // Fixme, leaks buf if throws.
180− cache.add_art(info.artist, info.album, buf, s);
179+ try {
180+ cache.add_art(info.artist, info.album, buf, s);
181+ } catch(...) {
182+ delete []buf;
183+ throw;
184+ }
181185 delete []buf;
182186 return cache.get_art_file(info.artist, info.album);
183187}