diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index 7b5160b81..04996e7c5 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -9268,18 +9268,10 @@ rtengine::Thumbnail* rtengine::Thumbnail::loadQuickFromRaw (const Glib::ustring& rml.ciffBase = ciff_base; rml.ciffLength = ciff_len; - char *thumb_buffer = (char *)malloc(thumb_length+64); // malloc instead of on the stack. - if ( thumb_buffer == NULL ) - { - printf("DCRAW: failed3\n"); - return NULL; - } - fseek(ifp,thumb_offset,SEEK_SET); - fread(thumb_buffer,1,thumb_length,ifp); + rtengine::Thumbnail* tpp = rtengine::Thumbnail::loadFromMemory(fdata(thumb_offset,ifp),thumb_length,w,h,fixwh); + fclose(ifp); - rtengine::Thumbnail* tpp = rtengine::Thumbnail::loadFromMemory(thumb_buffer,thumb_length,w,h,fixwh); - free(thumb_buffer); if ( tpp == 0 ) { printf("DCRAW: failed4\n"); diff --git a/rtengine/dcraw.patch b/rtengine/dcraw.patch index 15255941d..6f172437d 100644 --- a/rtengine/dcraw.patch +++ b/rtengine/dcraw.patch @@ -1,5 +1,5 @@ ---- dcraw.c 2010-11-11 08:44:21.000000000 -0700 -+++ dcraw.cc 2010-11-11 08:33:51.000000000 -0700 +--- dcraw.c 2010-11-11 20:35:59.000000000 -0500 ++++ dcraw.cc 2010-11-15 21:14:19.000000000 -0500 @@ -1,3 +1,15 @@ +/*RT*/#include +/*RT*/#include @@ -405,7 +405,7 @@ case 'f': four_color_rgb = 1; break; case 'A': FORC4 greybox[c] = atoi(argv[arg++]); case 'a': use_auto_wb = 1; break; -@@ -8943,3 +9007,602 @@ +@@ -8943,3 +9007,594 @@ } return status; } @@ -670,18 +670,10 @@ + rml.ciffBase = ciff_base; + rml.ciffLength = ciff_len; + -+ char *thumb_buffer = (char *)malloc(thumb_length+64); // malloc instead of on the stack. -+ if ( thumb_buffer == NULL ) -+ { -+ printf("DCRAW: failed3\n"); -+ return NULL; -+ } -+ fseek(ifp,thumb_offset,SEEK_SET); -+ fread(thumb_buffer,1,thumb_length,ifp); ++ rtengine::Thumbnail* tpp = rtengine::Thumbnail::loadFromMemory(fdata(thumb_offset,ifp),thumb_length,w,h,fixwh); ++ + fclose(ifp); + -+ rtengine::Thumbnail* tpp = rtengine::Thumbnail::loadFromMemory(thumb_buffer,thumb_length,w,h,fixwh); -+ free(thumb_buffer); + if ( tpp == 0 ) + { + printf("DCRAW: failed4\n"); diff --git a/rtengine/myfile.h b/rtengine/myfile.h index 99c450d8f..997340017 100644 --- a/rtengine/myfile.h +++ b/rtengine/myfile.h @@ -86,6 +86,10 @@ inline int fread (void* dst, int es, int count, IMFILE* f) { } } +inline char* fdata(int offset, IMFILE* f) { + return f->data + offset; +} + int fscanf (IMFILE* f, const char* s ...); char* fgets (char* s, int n, IMFILE* f); #endif