Skip to content

Commit

Permalink
limit the array size to avoid the casting out of range
Browse files Browse the repository at this point in the history
map is a array, which could be accessed by index, even the index is out of range.
Fixes intel#722

Signed-off-by: Carl Zhang <[email protected]>
  • Loading branch information
XinfengZhang committed Jul 17, 2023
1 parent f6a4e6a commit 6368270
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions va/drm/va_drm_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ VA_DRM_GetDriverNames(VADriverContextP ctx, char **drivers, unsigned *num_driver
if (strcmp(map[i].drm_driver, drm_driver) == 0) {
const char * const *va_drivers = map[i].va_driver;

while (va_drivers[count]) {
if (count < MAX_NAMES && count < *num_drivers)
while (count < MAX_NAMES && va_drivers[count]) {
if (count < *num_drivers)
drivers[count] = strdup(va_drivers[count]);
count++;
}
Expand Down

0 comments on commit 6368270

Please sign in to comment.