Merge lp:~jpakkane/thumbnailer/memfixes into lp:thumbnailer

Proposed by Jussi Pakkanen
Status: Merged
Approved by: Timo Jyrinki
Approved revision: 116
Merged at revision: 115
Proposed branch: lp:~jpakkane/thumbnailer/memfixes
Merge into: lp:thumbnailer
Diff against target: 60 lines (+9/-5)
3 files modified
plugins/Ubuntu/Thumbnailer/thumbnailgenerator.cpp (+2/-2)
src/thumbnailcache.cpp (+2/-1)
src/thumbnailer.cpp (+5/-2)
To merge this branch: bzr merge lp:~jpakkane/thumbnailer/memfixes
Reviewer Review Type Date Requested Status
Florian Boucault (community) functional Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
James Henstridge Approve
Review via email: mp+245550@code.launchpad.net

Commit message

Fix a few potential memory corruptions.

Description of the change

Fix a few potential memory corruptions.

To post a comment you must log in.
lp:~jpakkane/thumbnailer/memfixes updated
116. By Jussi Pakkanen

Else fix too, just for good measure.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Build available at silo 19 (created so I could test with the produced debs).

Revision history for this message
Florian Boucault (fboucault) wrote :

Seems to fix the bug

review: Approve (functional)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Ubuntu/Thumbnailer/thumbnailgenerator.cpp'
2--- plugins/Ubuntu/Thumbnailer/thumbnailgenerator.cpp 2014-09-25 08:58:38 +0000
3+++ plugins/Ubuntu/Thumbnailer/thumbnailgenerator.cpp 2015-01-05 09:28:13 +0000
4@@ -50,8 +50,8 @@
5 const int small_cutoff = 128;
6 if(requestedSize.width() > xlarge_cutoff || requestedSize.height() > xlarge_cutoff) {
7 desiredSize = TN_SIZE_ORIGINAL;
8- } if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) {
9- desiredSize = TN_SIZE_XLARGE;
10+ } else if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) {
11+ desiredSize = TN_SIZE_XLARGE;
12 } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) {
13 desiredSize = TN_SIZE_LARGE;
14 } else {
15
16=== modified file 'src/thumbnailcache.cpp'
17--- src/thumbnailcache.cpp 2014-09-18 09:03:14 +0000
18+++ src/thumbnailcache.cpp 2015-01-05 09:28:13 +0000
19@@ -237,7 +237,7 @@
20 if(normalized) {
21 buf = (const unsigned char*)normalized;
22 }
23- gssize bytes = str.length();
24+ gssize bytes = strlen((const char*)buf);
25
26 result = g_compute_checksum_for_data(G_CHECKSUM_MD5, buf, bytes);
27 final_result = result;
28@@ -247,6 +247,7 @@
29 }
30
31 string ThumbnailCachePrivate::get_cache_file_name(const std::string & abs_original, ThumbnailSize desired) const {
32+ assert(!abs_original.empty());
33 assert(abs_original[0] == '/');
34 string path;
35 switch(desired) {
36
37=== modified file 'src/thumbnailer.cpp'
38--- src/thumbnailer.cpp 2014-11-06 05:37:51 +0000
39+++ src/thumbnailer.cpp 2015-01-05 09:28:13 +0000
40@@ -92,8 +92,8 @@
41 exif_loader_write_file(el.get(), abspath.c_str());
42 std::unique_ptr<ExifData, void(*)(ExifData*e)> ed(exif_loader_get_data(el.get()), exif_data_unref);
43 if(ed && ed->data && ed->size) {
44- auto outfile = create_random_filename().c_str();
45- FILE *thumb = fopen(outfile, "wb");
46+ auto outfile = create_random_filename();
47+ FILE *thumb = fopen(outfile.c_str(), "wb");
48 if(thumb) {
49 fwrite(ed->data, 1, ed->size, thumb);
50 fclose(thumb);
51@@ -215,6 +215,9 @@
52 std::string Thumbnailer::get_thumbnail(const std::string &filename, ThumbnailSize desired_size,
53 ThumbnailPolicy policy) {
54 string abspath;
55+ if(filename.empty()) {
56+ return "";
57+ }
58 if(filename[0] != '/') {
59 auto cwd = getcwd(nullptr, 0);
60 abspath += cwd;

Subscribers

People subscribed via source and target branches

to all changes: