~jamesh/thumbnailer/landing-20150622

« back to all changes in this revision

Viewing changes to src/thumbnailer.cpp

  • Committer: CI Train Bot
  • Author(s): Jussi Pakkanen
  • Date: 2015-01-06 18:50:35 UTC
  • mfrom: (114.1.2 thumbnailer)
  • Revision ID: ci_train_bot_citrain_user@canonical.com-20150106185035-3vl3mdrchpvrptwl
Fix a few potential memory corruptions. Fixes: #1403906
Approved by: James Henstridge

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
        exif_loader_write_file(el.get(), abspath.c_str());
93
93
        std::unique_ptr<ExifData, void(*)(ExifData*e)> ed(exif_loader_get_data(el.get()), exif_data_unref);
94
94
        if(ed && ed->data && ed->size) {
95
 
            auto outfile = create_random_filename().c_str();
96
 
            FILE *thumb = fopen(outfile, "wb");
 
95
            auto outfile = create_random_filename();
 
96
            FILE *thumb = fopen(outfile.c_str(), "wb");
97
97
            if(thumb) {
98
98
                fwrite(ed->data, 1, ed->size, thumb);
99
99
                fclose(thumb);
215
215
std::string Thumbnailer::get_thumbnail(const std::string &filename, ThumbnailSize desired_size,
216
216
        ThumbnailPolicy policy) {
217
217
    string abspath;
 
218
    if(filename.empty()) {
 
219
        return "";
 
220
    }
218
221
    if(filename[0] != '/') {
219
222
        auto cwd = getcwd(nullptr, 0);
220
223
        abspath += cwd;