Bug 119352 - [PATCH] [testcase] Formatting of large roman numbers leads to undefined behavior
Summary: [PATCH] [testcase] Formatting of large roman numbers leads to undefined behavior
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: unspecified
Platform: NetBSD pkgsrc Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-02 01:17 UTC by Roland Illig
Modified: 2006-01-19 18:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
testcase (427 bytes, text/html)
2006-01-02 01:35 UTC, Thiago Macieira
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Illig 2006-01-02 01:17:37 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    NetBSD pkgsrc
Compiler:          any 

This patch fixes the undefined behavior when formatting big numbers in
roman.

--- khtml/rendering/enumerate.cpp.orig  Mon Oct 10 17:06:06 2005
+++ khtml/rendering/enumerate.cpp       Sun Jan  1 22:07:12 2006
@@ -34,7 +34,7 @@ namespace Enumerate {
 
 QString toRoman( int number, bool upper )
 {
-    if (number < 1) return QString::number(number);
+    if (number < 1 || number > 3999) return QString::number(number);
     QString roman;
     static const QChar ldigits[] = { 'i', 'v', 'x', 'l', 'c', 'd', 'm' };
     static const QChar udigits[] = { 'I', 'V', 'X', 'L', 'C', 'D', 'M' };
Comment 1 Maksim Orlovich 2006-01-02 01:21:58 UTC
Thanks for the patch. Any place on the web actually use that, or should I stop being lazy and make a testcase? ;-)
Comment 2 Thiago Macieira 2006-01-02 01:35:07 UTC
Created attachment 14102 [details]
testcase
Comment 3 Thiago Macieira 2006-01-02 01:35:40 UTC
Forgot to confirm.
Comment 4 Maksim Orlovich 2006-01-19 18:53:06 UTC
SVN commit 500228 by orlovich:

Apply patch from Roland Illig (roland dot illig at the host gmx with tld de) 
to behave sanely for Roman counters > 4000
BUG:119352



 M  +1 -1      enumerate.cpp  


--- branches/KDE/3.5/kdelibs/khtml/rendering/enumerate.cpp #500227:500228
@@ -34,7 +34,7 @@
 
 QString toRoman( int number, bool upper )
 {
-    if (number < 1) return QString::number(number);
+    if (number < 1 || number > 3999) return QString::number(number);
     QString roman;
     static const QChar ldigits[] = { 'i', 'v', 'x', 'l', 'c', 'd', 'm' };
     static const QChar udigits[] = { 'I', 'V', 'X', 'L', 'C', 'D', 'M' };
Comment 5 Maksim Orlovich 2006-01-19 18:59:00 UTC
SVN commit 500230 by orlovich:

Regression test for #119352
CCBUG:119352


 A             baseline/unsorted/119352.html-dom  
 AM            baseline/unsorted/119352.html-dump.png  
 A             baseline/unsorted/119352.html-render  
 A             tests/unsorted/119352.html  


** trunk/tests/khtmltests/regression/baseline/unsorted/119352.html-dump.png #property svn:mime-type
   + application/octet-stream