Bug 412585

Summary: po_thumbnailer crash when the po files contains no string
Product: [Frameworks and Libraries] kio-extras Reporter: liushuyu
Component: Thumbnails and previewsAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: kde, liushuyu, nate
Priority: NOR    
Version First Reported In: 19.08.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description liushuyu 2019-10-04 01:43:37 UTC
po_thumbnailer will crash when a PO file does not contain any translatable string


STEPS TO REPRODUCE
1. touch empty.po
2. refresh the folder
3. crash

OBSERVED RESULT
Dr. Konqi reported a crash in kdeinit5.

EXPECTED RESULT
At least no crash

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.16.5
KDE Frameworks Version: 5.62.0
Qt Version: 5.13.1
Kernel Version: 5.3.1-zen1-1-zen
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 31.3 GiB

ADDITIONAL INFORMATION
The backtrace shows the problem is at `po_thumbnailer/pocreator.cpp:128` where `total = 0` (division by zero).
Recommendation: add `total = total > 0 ? total : 1;` or just return with nothing.
Comment 1 Nate Graham 2019-10-07 13:23:42 UTC
Nice find! Looks like the code comes from a 3rd-party plugin: https://store.kde.org/p/1081171/. I would recommend contacting the author: https://www.pling.com/u/nihui/
Comment 2 liushuyu 2019-10-27 02:50:49 UTC
Sorry for the late response, the e-mail landed in the Junk Folder.

>Nice find! Looks like the code comes from a 3rd-party plugin: https://store.kde.org/p/1081171/. I would recommend contacting the author: https://www.pling.com/u/nihui/

I downloaded the source code from https://download.kde.org/stable/applications/19.08.2/src/kdesdk-thumbnailers-19.08.2.tar.xz so it means that the software under this site isn't written by KDE? This is very weird.

Also, I have never downloaded the aforementioned plugin to my system and this plugin wasn't bundled with the install whatsoever.
Comment 3 David Edmundson 2019-10-27 15:31:29 UTC
https://phabricator.kde.org/D24984
Comment 4 David Edmundson 2019-10-31 14:59:34 UTC
Git commit de3c82950d9a9bdfb3cfb8897b1d12eaa200066e by David Edmundson.
Committed on 31/10/2019 at 14:59.
Pushed by davidedmundson into branch 'Applications/19.08'.

[pocreator] Avoid divide by 0

Summary:
If a po file has no strings, the current code will divide by 0 when
trying to draw some pie charts.

This patch aborts early which falls back to a regular icon.

Test Plan:
touch empty.po
open dolphin in cwd

Reviewers: ngraham

Reviewed By: ngraham

Subscribers: ngraham

Differential Revision: https://phabricator.kde.org/D24984

M  +5    -0    po_thumbnailer/pocreator.cpp

https://commits.kde.org/kdesdk-thumbnailers/de3c82950d9a9bdfb3cfb8897b1d12eaa200066e