Mesa (staging/21.3): vbo/dlist: free copied.buffer if no vertices were copied

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 4 22:59:17 UTC 2021


Module: Mesa
Branch: staging/21.3
Commit: da759c47d61a1ac3d9fe2a6a6878654cca5c4e74
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=da759c47d61a1ac3d9fe2a6a6878654cca5c4e74

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Mon Oct  4 11:18:47 2021 +0200

vbo/dlist: free copied.buffer if no vertices were copied

Other parts of the code asserts that copied.buffer is NULL if there are
no vertices to copy.

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13246>
(cherry picked from commit 9b09655a587f03b4096df0a4314e98a267816cfa)

---

 .pick_status.json           | 2 +-
 src/mesa/vbo/vbo_save_api.c | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 82c116e8f49..54c4181accd 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -364,7 +364,7 @@
         "description": "vbo/dlist: free copied.buffer if no vertices were copied",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 7f2b1d4b917..051ba763b46 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -168,8 +168,13 @@ copy_vertices(struct gl_context *ctx,
    assert(save->copied.buffer == NULL);
    save->copied.buffer = malloc(sizeof(fi_type) * sz * prim->count);
 
-   return vbo_copy_vertices(ctx, prim->mode, prim->start, &prim->count,
-                            prim->begin, sz, true, save->copied.buffer, src);
+   unsigned r = vbo_copy_vertices(ctx, prim->mode, prim->start, &prim->count,
+                                  prim->begin, sz, true, save->copied.buffer, src);
+   if (!r) {
+      free(save->copied.buffer);
+      save->copied.buffer = NULL;
+   }
+   return r;
 }
 
 



More information about the mesa-commit mailing list