Review Request 127488: Fix usage of std::isprint() function

Dominik Haumann dhaumann at kde.org
Thu Mar 24 21:15:00 UTC 2016



> On March 24, 2016, 9:11 p.m., Dominik Haumann wrote:
> > Btw: If you think QChar::isPrint() is a better choice [1], I'm happy to update the review request accordingly.
> > 
> > [1] http://doc.qt.io/qt-5/qchar.html#isPrint-1

Oh, and for a correct review, the isprint() comes from https://lxr.kde.org/source/frameworks/kcodecs/src/probers/ctype_test_p.h
This, however, just shows again that -31 is used as index in an array.


- Dominik


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/127488/#review93946
-----------------------------------------------------------


On March 24, 2016, 9:06 p.m., Dominik Haumann wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/127488/
> -----------------------------------------------------------
> 
> (Updated March 24, 2016, 9:06 p.m.)
> 
> 
> Review request for KDE Frameworks.
> 
> 
> Bugs: 357341
>     https://bugs.kde.org/show_bug.cgi?id=357341
> 
> 
> Repository: kcodecs
> 
> 
> Description
> -------
> 
> With the patch in review request https://git.reviewboard.kde.org/r/127486/ I get another crash when loading the attached file in bug https://bugs.kde.org/show_bug.cgi?id=360797
> 
> The issue is the call if isprint(int): Accoring to http://en.cppreference.com/w/cpp/string/byte/isprint
> "the behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF."
> 
> In this case, casting the char to an int results "-31", which is clearly not representable as *unsigned* char. Hence, we indeed hit the "undefined behavior" and get a crash.
> 
> This patch therefore
> - casts the char to an int first
> - and then checks whether the int it non-negative
> - only then, isprint() is called.
> 
> 
> Diffs
> -----
> 
>   src/probers/UnicodeGroupProber.cpp 1d86f08 
> 
> Diff: https://git.reviewboard.kde.org/r/127488/diff/
> 
> 
> Testing
> -------
> 
> Kate/Kwrite launch without crash.
> Unit tests still pass.
> 
> 
> Thanks,
> 
> Dominik Haumann
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20160324/43772e54/attachment.html>


More information about the Kde-frameworks-devel mailing list