mesa: fix format conversion bug in get_tex_rgba_uncompressed()
authorBrian Paul <brianp@vmware.com>
Mon, 29 Aug 2016 17:18:18 +0000 (11:18 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 29 Aug 2016 23:46:50 +0000 (17:46 -0600)
We need to set the need_convert flag with each loop iteration, not
just when the rgba pointer is null.

Bug reported by Markus Müller <mueller@imfusion.de> on mesa-users list.
Fixes new piglit arb_texture_float-get-tex3d test.

Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/main/texgetimage.c

index bd44c68776924c5a10a2d33e703f7de95a5f4efb..b9002787344f86d7cc0cb3886f9f00d4cf174c75 100644 (file)
@@ -495,13 +495,15 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
           */
          if (format == rgba_format) {
             rgba = dest;
-         } else if (rgba == NULL) { /* Allocate the RGBA buffer only once */
+         } else {
             need_convert = true;
-            rgba = malloc(height * rgba_stride);
-            if (!rgba) {
-               _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()");
-               ctx->Driver.UnmapTextureImage(ctx, texImage, img);
-               return;
+            if (rgba == NULL) { /* Allocate the RGBA buffer only once */
+               rgba = malloc(height * rgba_stride);
+               if (!rgba) {
+                  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()");
+                  ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+                  return;
+               }
             }
          }