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>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user