st/nine: Fix resource9 private data
authorPatrick Rudolph <siro@das-labor.org>
Sat, 14 Nov 2015 12:02:43 +0000 (13:02 +0100)
committerAxel Davy <axel.davy@ens.fr>
Thu, 4 Feb 2016 21:12:17 +0000 (22:12 +0100)
Store a copy of GUID in the header that is under our control and use it
as key for the hashtable instead of using the application provided pointer.
The application might change the memory after leaving the function.

Fixes a crash for issue https://github.com/iXit/Mesa-3D/issues/130

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/nine_pdata.h
src/gallium/state_trackers/nine/resource9.c

index 7bdd702cfbbd255d9fce49e11ee4b1ba31ed7f89..0e9a2aa716006e1bd867599c7145588285761773 100644 (file)
@@ -5,6 +5,7 @@
 struct pheader
 {
     boolean unknown;
+    GUID guid;
     DWORD size;
     char data[1];
 };
index f3c26896aaf67fd0d553b3ac3990e90af75386ef..56e85156a2929d3e7a02cd061077ea2b1fc75874 100644 (file)
@@ -141,8 +141,9 @@ NineResource9_SetPrivateData( struct NineResource9 *This,
 
     header->size = SizeOfData;
     memcpy(header->data, user_data, header->size);
+    memcpy(&header->guid, refguid, sizeof(header->guid));
 
-    err = util_hash_table_set(This->pdata, refguid, header);
+    err = util_hash_table_set(This->pdata, &header->guid, header);
     if (err == PIPE_OK) {
         if (header->unknown) { IUnknown_AddRef(*(IUnknown **)header->data); }
         return D3D_OK;