DiscussionsIssue archiveOCCT:Visualization

Archived issue #0023842

Undefined behavior: Variable 'thePsFont' is used as parameter and destination in s[n]printf()

CommunityOCCT:Visualizationclosed5 public notes

Search issues

Description

In OpenGl_Text.cxx, line 96:

sprintf (thePsFont, "%s%s", thePsFont, TheItalic[aFontId]);

cppcheck message:
"The variable 'thePsFont' is used both as a parameter and as destination in s[n]printf(). The origin and destination buffers overlap. Quote from glibc (C-library) documentation (http://www.gnu.org/software/libc/manual/html_mono/libc.html#Formatted-Output-Functions): "If copying takes place between objects that overlap as a result of a call to sprintf() or snprintf(), the results are undefined.""

Public activity

5 archived notes

Participants are labeled by their role within this record.

01Commenter 1
The offending code has been introduced in #0023457
02Commenter 1
> The offending code has been introduced in 0023457
No it didn't.

03Commenter 1
Patch is ready for review in CR23842 branch.
04Commenter 4
Branch CR23842 reviewed without remarks, ready for testing.
05Commenter 5
Dear BugMaster,

Branch CR23842 (and products from GIT master) was compiled on Linux and Windows platforms and tested without rebase.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 3 (3 on master)
Windows: 11 (11 on master)

products component :
Linux: 0 (0 on master)
Windows: 50 (50 on master)

Regressions:
No regressions

Improvements:
No improvements

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 243477684 / 241671364
Total CPU difference: 17405.350000000162 / 14694.200000000103

Testing on Windows:
Total MEMORY difference: 352774980 / 354810080
Total CPU difference: 21124.578125 / 22916.015625

There are not serious differences in images found by testdiff.