[Digikam-devel] [Bug 261015] Digikam Fingerprinter crashes

Daniel Scharrer dscharrer at gmail.com
Thu Dec 23 12:12:15 GMT 2010


https://bugs.kde.org/show_bug.cgi?id=261015





--- Comment #2 from Daniel Scharrer <dscharrer gmail com>  2010-12-23 13:12:14 ---
The problem seems to be a 1-pixel high image being scaled down and the
destination height being calculatet as 0, leading to divide by zero and
possibly other errors later on.

This could be caused by Digikam::FingerPrintsGenerator::slotGotImagePreview
passing 0 as the dh parameter.

More likely though, the this is caused by the newSize.scale( QSize(dw, dh),
aspectRatioMode ); in Digikam::DImg::smoothScale always rounding down the
result.

To solve this, you need to check if the calculated dh or dw are equal to zero
and then either abort (since the new image has zero height/width there is
nothing to du) or better yet just bump the height/width up to a minimum of one
(a thumbnail with only one row of pixels is still more useful than an empty
thumbnail, no?).

So that would mean to add in Digikam::DImg::smoothScale after
dw = newSize.width();
dh = newSize.height();
add
if(dw == 0) {
 dw = 1;
}
if(dh == 0) {
 dh = 1;
}

Because I don't have the source code checked out right now (and don't have time
to do so) I can't provide proper diff file or test the changes myself, but just
adding thos chechs for dw == 0 and dh == 0 should fix this crash.

Note that this change will result in Digikam::DImg::smoothScale always
returning an image width width and height of at least one, even if the passed
dw and/or dh are zero, which may or may not be desirable. However, this should
not break any existing uses of the smoothScale, as passing 0 as dw or dh
results in a crash without this change.

Happy holidays,
Daniel

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Digikam-devel mailing list