[Mesa-dev] [PATCH 1/5] pipe-loader: check if winsys.name is non-null prior to strcmp

Emil Velikov emil.l.velikov at gmail.com
Mon Nov 23 12:26:55 PST 2015


In theory this wouldn't be an issue, as we'll find the correct name and
break out of the loop before we hit the sentinel.

Let's fix this and avoid issues in the future.

Spotted by Coverity.

Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index 5539a73..6c1571b 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -136,7 +136,7 @@ pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct drisw_loader_f
    if (!pipe_loader_sw_probe_init_common(sdev))
       goto fail;
 
-   for (i = 0; sdev->dd->winsys; i++) {
+   for (i = 0; sdev->dd->winsys[i].name; i++) {
       if (strcmp(sdev->dd->winsys[i].name, "dri") == 0) {
          sdev->ws = sdev->dd->winsys[i].create_winsys(drisw_lf);
          break;
@@ -168,7 +168,7 @@ pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd)
    if (!pipe_loader_sw_probe_init_common(sdev))
       goto fail;
 
-   for (i = 0; sdev->dd->winsys; i++) {
+   for (i = 0; sdev->dd->winsys[i].name; i++) {
       if (strcmp(sdev->dd->winsys[i].name, "kms_dri") == 0) {
          sdev->ws = sdev->dd->winsys[i].create_winsys(fd);
          break;
@@ -199,7 +199,7 @@ pipe_loader_sw_probe_null(struct pipe_loader_device **devs)
    if (!pipe_loader_sw_probe_init_common(sdev))
       goto fail;
 
-   for (i = 0; sdev->dd->winsys; i++) {
+   for (i = 0; sdev->dd->winsys[i].name; i++) {
       if (strcmp(sdev->dd->winsys[i].name, "null") == 0) {
          sdev->ws = sdev->dd->winsys[i].create_winsys();
          break;
@@ -244,7 +244,7 @@ pipe_loader_sw_probe_wrapped(struct pipe_loader_device **dev,
    if (!pipe_loader_sw_probe_init_common(sdev))
       goto fail;
 
-   for (i = 0; sdev->dd->winsys; i++) {
+   for (i = 0; sdev->dd->winsys[i].name; i++) {
       if (strcmp(sdev->dd->winsys[i].name, "wrapped") == 0) {
          sdev->ws = sdev->dd->winsys[i].create_winsys(screen);
          break;
-- 
2.6.2



More information about the mesa-dev mailing list