gallium/u_upload_mgr: fix a serious memory leak
authorMarek Olšák <maraeo@gmail.com>
Mon, 28 Jan 2013 01:47:24 +0000 (02:47 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 28 Jan 2013 01:51:52 +0000 (02:51 +0100)
It can eat all memory and crash in a matter of minutes with r600g.

src/gallium/auxiliary/util/u_upload_mgr.c

index 47d39af67aaeca1f6fbb1213075b104e129a6e1c..6859751c59178996f278d6f99b5b6e52aece6310 100644 (file)
@@ -167,7 +167,7 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
     * sure the caller doesn't get garbage values.
     */
    *out_offset = ~0;
-   *outbuf = NULL;
+   pipe_resource_reference(outbuf, NULL);
    *ptr = NULL;
 
    /* Make sure we have enough space in the upload buffer
@@ -189,7 +189,6 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
                                          PIPE_TRANSFER_UNSYNCHRONIZED,
                                          &upload->transfer);
       if (!upload->map) {
-         pipe_resource_reference(outbuf, NULL);
          upload->transfer = NULL;
          return PIPE_ERROR_OUT_OF_MEMORY;
       }