on xenial help sign in
Free resource in case of exceptions.
dcbcea2Jussi Pakkanen
plugins/Utils/albumartprovider.cpp+6−2
@@ -176,8 +176,12 @@ std::string AlbumArtProvider::get_image(const std::string &artist, const std::st
176 fread(buf, 1, s, f);
176 fread(buf, 1, s, f);
177 fclose(f);
177 fclose(f);
178
178
179− // Fixme, leaks buf if throws.
179+ try {
180− cache.add_art(info.artist, info.album, buf, s);
180+ cache.add_art(info.artist, info.album, buf, s);
181+ } catch(...) {
182+ delete []buf;
183+ throw;
184+ }
181 delete []buf;
185 delete []buf;
182 return cache.get_art_file(info.artist, info.album);
186 return cache.get_art_file(info.artist, info.album);
183}
187}