mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-15 22:08:17 +02:00
pipe-loader: avoid undefined memcpy behavior
If either dest or src is an invalid or null pointer, the behavior is
undefined, even if count is zero.
Cc: mesa-stable
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22979>
(cherry picked from commit 5b31039033)
This commit is contained in:
parent
1fa4d3af65
commit
24e1a5ebaf
2 changed files with 7 additions and 3 deletions
|
|
@ -3883,7 +3883,7 @@
|
|||
"description": "pipe-loader: avoid undefined memcpy behavior",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
|
|
|||
|
|
@ -97,8 +97,12 @@ merge_driconf(const driOptionDescription *driver_driconf, unsigned driver_count,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(merged, gallium_driconf, sizeof(*merged) * gallium_count);
|
||||
memcpy(&merged[gallium_count], driver_driconf, sizeof(*merged) * driver_count);
|
||||
if (gallium_count)
|
||||
memcpy(merged, gallium_driconf, sizeof(*merged) * gallium_count);
|
||||
if (driver_count) {
|
||||
memcpy(&merged[gallium_count], driver_driconf,
|
||||
sizeof(*merged) * driver_count);
|
||||
}
|
||||
|
||||
*merged_count = driver_count + gallium_count;
|
||||
return merged;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue