Repository navigation
lib/psdriver: Print double coordinates with %f, not %d - #7700
Merged
Merged
Conversation
PS_Bitmap passed the double cur_x and cur_y and PS_Erase passed the double ps.left, ps.top, ps.right and ps.bot to output() as %d. On x86_64 this reads the wrong varargs registers, so BITMAP and BOX received garbage operands. Use %f as box.c already does for the same BOX procedure. Fixes 6 CodeQL cpp/wrong-type-format-argument alerts.
petrasovaa
approved these changes
Jul 14, 2026
Member
|
@cwhite911 Please look at this PR: #3551 it was the same file, also about bad argument types, and the review got postponed indefinitely because of an unanswered question. What made this PR resolve that question? Is the other PR still need to be open now, even though line 44 wasn’t changed? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes 6 CodeQL
cpp/wrong-type-format-argumentalerts (error severity), all in the PS driver:draw_bitmap.c:PS_Bitmap()printed thedoubleglobalscur_x,cur_ywith%derase.c:PS_Erase()printed thedoublefieldsps.left,ps.top,ps.right,ps.botwith%dThis is a real bug, not just a style issue: on x86_64 the doubles go into SSE registers while
%dreads the integer registers, so the emitted PostScript operators received garbage operands. Before the fix,d.text(with a freetype font) emitted e.g.(glyph size in the position slots, garbage for the rest). After the fix:
%fmatches howbox.calready prints the sameBOXprocedure, and theBITMAPprolog passes the first two operands totranslate, which accepts reals (the integer-onlyidivoperates onncols, which stays%d).Verified by compiling and rendering
d.erase -fandd.textwithGRASS_RENDER_IMMEDIATE=psand inspecting the output above.This is part of a larger effort to work through the open code scanning alerts, grouped into small PRs by issue type.
Written with the assistance of Claude Code.