(release/25.2) xf86: prevent passing NULL pointer as strcat() destination - #3568
Open
metux wants to merge 1 commit into
Conversation
metux
pushed a commit
that referenced
this pull request
Aug 20, 2026
Reported by gcc 16.1:
hw/xfree86/parser/Files.c:119:17: warning: use of NULL where non-null
expected [CWE-476] [-Wanalyzer-null-argument]
119 | strcat(ptr->file_fontpath, ",");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
117 | ptr->file_fontpath = realloc(ptr->file_fontpath, i);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) when ‘realloc’ fails
| (10) using NULL here
118 | if (j)
| ~
| |
| (11) following ‘true’ branch (when ‘j != 0’)... ─>─┐
| │
| │
|┌──────────────────────────────────────────────────────────────────┘
119 |│ strcat(ptr->file_fontpath, ",");
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ |
|└───────────────>(12) ...to here
| (13) ⚠ argument 1 (‘realloc(*ptr.file_fontpath, (long unsigned int)i)’) NULL where non-null expected
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
......
| │
|┌──────────────────────────────────────────────────────────────────┘
121 |│ strcat(ptr->file_fontpath, str);
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ | |
|│ | (10) using NULL here
|└───────────>(9) ...to here
| (11) ⚠ argument 1 (‘*ptr.file_fontpath’) NULL where non-null expected
note: argument 1 of ‘strcat’ must be non-null
hw/xfree86/parser/Files.c:144:17: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
144 | strcat(ptr->file_modulepath, ",");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
142 | ptr->file_modulepath = realloc(ptr->file_modulepath, k);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) when ‘realloc’ fails
| (10) using NULL here
143 | if (l)
| ~
| |
| (11) following ‘true’ branch (when ‘l != 0’)... ─>─┐
| │
| │
|┌──────────────────────────────────────────────────────────────────┘
144 |│ strcat(ptr->file_modulepath, ",");
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ |
|└───────────────>(12) ...to here
| (13) ⚠ argument 1 (‘realloc(*ptr.file_modulepath, (long unsigned int)k)’) NULL where non-null expected
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
......
| │
|┌──────────────────────────────────────────────────────────────────┘
146 |│ strcat(ptr->file_modulepath, str);
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ | |
|│ | (10) using NULL here
|└───────────>(9) ...to here
| (11) ⚠ argument 1 (‘*ptr.file_modulepath’) NULL where non-null expected
note: argument 1 of ‘strcat’ must be non-null
Also clears two -Wanalyzer-malloc-leak warnings for leaking the old
pointer when realloc() failed, now that realloc() cannot fail.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2272>
PR: #3568
Contributor
Author
Review: xf86: prevent passing NULL pointer as strcat() destinationReplaces Code review (1 file, +3/-4)
Checklist
VerdictPassed. Clean, minimal fix. Follows established |
This was referenced Aug 20, 2026
Reported by gcc 16.1:
hw/xfree86/parser/Files.c:119:17: warning: use of NULL where non-null
expected [CWE-476] [-Wanalyzer-null-argument]
119 | strcat(ptr->file_fontpath, ",");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
117 | ptr->file_fontpath = realloc(ptr->file_fontpath, i);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) when ‘realloc’ fails
| (10) using NULL here
118 | if (j)
| ~
| |
| (11) following ‘true’ branch (when ‘j != 0’)... ─>─┐
| │
| │
|┌──────────────────────────────────────────────────────────────────┘
119 |│ strcat(ptr->file_fontpath, ",");
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ |
|└───────────────>(12) ...to here
| (13) ⚠ argument 1 (‘realloc(*ptr.file_fontpath, (long unsigned int)i)’) NULL where non-null expected
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
......
| │
|┌──────────────────────────────────────────────────────────────────┘
121 |│ strcat(ptr->file_fontpath, str);
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ | |
|│ | (10) using NULL here
|└───────────>(9) ...to here
| (11) ⚠ argument 1 (‘*ptr.file_fontpath’) NULL where non-null expected
note: argument 1 of ‘strcat’ must be non-null
hw/xfree86/parser/Files.c:144:17: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
144 | strcat(ptr->file_modulepath, ",");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
142 | ptr->file_modulepath = realloc(ptr->file_modulepath, k);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) when ‘realloc’ fails
| (10) using NULL here
143 | if (l)
| ~
| |
| (11) following ‘true’ branch (when ‘l != 0’)... ─>─┐
| │
| │
|┌──────────────────────────────────────────────────────────────────┘
144 |│ strcat(ptr->file_modulepath, ",");
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ |
|└───────────────>(12) ...to here
| (13) ⚠ argument 1 (‘realloc(*ptr.file_modulepath, (long unsigned int)k)’) NULL where non-null expected
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
......
| │
|┌──────────────────────────────────────────────────────────────────┘
146 |│ strcat(ptr->file_modulepath, str);
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ | |
|│ | (10) using NULL here
|└───────────>(9) ...to here
| (11) ⚠ argument 1 (‘*ptr.file_modulepath’) NULL where non-null expected
note: argument 1 of ‘strcat’ must be non-null
Also clears two -Wanalyzer-malloc-leak warnings for leaking the old
pointer when realloc() failed, now that realloc() cannot fail.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2272>
metux
force-pushed
the
pr/release/25.2-xf86-prevent-passing-null-pointer-as-strcat-destination-_2026-08-20_15-41-57
branch
from
August 24, 2026 12:01
04eaeab to
0174a46
Compare
metux
pushed a commit
that referenced
this pull request
Aug 25, 2026
Reported by gcc 16.1:
hw/xfree86/parser/Files.c:119:17: warning: use of NULL where non-null
expected [CWE-476] [-Wanalyzer-null-argument]
119 | strcat(ptr->file_fontpath, ",");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
117 | ptr->file_fontpath = realloc(ptr->file_fontpath, i);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) when ‘realloc’ fails
| (10) using NULL here
118 | if (j)
| ~
| |
| (11) following ‘true’ branch (when ‘j != 0’)... ─>─┐
| │
| │
|┌──────────────────────────────────────────────────────────────────┘
119 |│ strcat(ptr->file_fontpath, ",");
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ |
|└───────────────>(12) ...to here
| (13) ⚠ argument 1 (‘realloc(*ptr.file_fontpath, (long unsigned int)i)’) NULL where non-null expected
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
......
| │
|┌──────────────────────────────────────────────────────────────────┘
121 |│ strcat(ptr->file_fontpath, str);
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ | |
|│ | (10) using NULL here
|└───────────>(9) ...to here
| (11) ⚠ argument 1 (‘*ptr.file_fontpath’) NULL where non-null expected
note: argument 1 of ‘strcat’ must be non-null
hw/xfree86/parser/Files.c:144:17: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
144 | strcat(ptr->file_modulepath, ",");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
142 | ptr->file_modulepath = realloc(ptr->file_modulepath, k);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) when ‘realloc’ fails
| (10) using NULL here
143 | if (l)
| ~
| |
| (11) following ‘true’ branch (when ‘l != 0’)... ─>─┐
| │
| │
|┌──────────────────────────────────────────────────────────────────┘
144 |│ strcat(ptr->file_modulepath, ",");
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ |
|└───────────────>(12) ...to here
| (13) ⚠ argument 1 (‘realloc(*ptr.file_modulepath, (long unsigned int)k)’) NULL where non-null expected
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
......
| │
|┌──────────────────────────────────────────────────────────────────┘
146 |│ strcat(ptr->file_modulepath, str);
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ | |
|│ | (10) using NULL here
|└───────────>(9) ...to here
| (11) ⚠ argument 1 (‘*ptr.file_modulepath’) NULL where non-null expected
note: argument 1 of ‘strcat’ must be non-null
Also clears two -Wanalyzer-malloc-leak warnings for leaking the old
pointer when realloc() failed, now that realloc() cannot fail.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2272>
PR: #3568
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.
Backport of #3568 (master)
Reported by gcc 16.1:
hw/xfree86/parser/Files.c:119:17: warning: use of NULL where non-null
expected [CWE-476] [-Wanalyzer-null-argument]
119 | strcat(ptr->file_fontpath, ",");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
117 | ptr->file_fontpath = realloc(ptr->file_fontpath, i);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) when ‘realloc’ fails
| (10) using NULL here
118 | if (j)
| ~
| |
| (11) following ‘true’ branch (when ‘j != 0’)... ─>─┐
| │
| │
|┌──────────────────────────────────────────────────────────────────┘
119 |│ strcat(ptr->file_fontpath, ",");
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ |
|└───────────────>(12) ...to here
| (13) ⚠ argument 1 (‘realloc(*ptr.file_fontpath, (long unsigned int)i)’) NULL where non-null expected
: note: argument 1 of ‘__builtin_strlen’ must be non-null
......
| │
|┌──────────────────────────────────────────────────────────────────┘
121 |│ strcat(ptr->file_fontpath, str);
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ | |
|│ | (10) using NULL here
|└───────────>(9) ...to here
| (11) ⚠ argument 1 (‘*ptr.file_fontpath’) NULL where non-null expected
note: argument 1 of ‘strcat’ must be non-null
hw/xfree86/parser/Files.c:144:17: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
144 | strcat(ptr->file_modulepath, ",");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
142 | ptr->file_modulepath = realloc(ptr->file_modulepath, k);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) when ‘realloc’ fails
| (10) using NULL here
143 | if (l)
| ~
| |
| (11) following ‘true’ branch (when ‘l != 0’)... ─>─┐
| │
| │
|┌──────────────────────────────────────────────────────────────────┘
144 |│ strcat(ptr->file_modulepath, ",");
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ |
|└───────────────>(12) ...to here
| (13) ⚠ argument 1 (‘realloc(*ptr.file_modulepath, (long unsigned int)k)’) NULL where non-null expected
: note: argument 1 of ‘__builtin_strlen’ must be non-null
......
| │
|┌──────────────────────────────────────────────────────────────────┘
146 |│ strcat(ptr->file_modulepath, str);
|│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|│ | |
|│ | (10) using NULL here
|└───────────>(9) ...to here
| (11) ⚠ argument 1 (‘*ptr.file_modulepath’) NULL where non-null expected
note: argument 1 of ‘strcat’ must be non-null
Also clears two -Wanalyzer-malloc-leak warnings for leaking the old
pointer when realloc() failed, now that realloc() cannot fail.
Signed-off-by: Alan Coopersmith alan.coopersmith@oracle.com
Part-of: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2272