Skip to content

Commit

Permalink
drm: limit the array size to avoid 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 18, 2023
1 parent fe87f9c commit 831b653
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions va/drm/va_drm_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,9 @@ VA_DRM_GetDriverNames(VADriverContextP ctx, char **drivers, unsigned *num_driver
for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
if (strcmp(map[i].drm_driver, drm_driver) == 0) {
const char * const *va_drivers = map[i].va_driver;
for ( ; count < MAX_NAMES && va_drivers[count] && count < *num_drivers; count++)
drivers[count] = strdup(va_drivers[count]);

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

0 comments on commit 831b653

Please sign in to comment.