Start the lifetime of the texture reference

reinterpret_cast<> doesn't create an object, so the texref is actually unitiliazed. This may lead to garbage data in some of its struct members.

Initialize it by performing a placement new. The constructer should set all of its members to default values. There's no way currently to extract the channel type, so use single channel char for now.

Change-Id: I41b305a75bb3f30130324de785099f55b3e130c7
此提交包含在:
Vladislav Sytchenko
2020-03-18 12:23:11 -04:00
父節點 117f0ab102
當前提交 292d008a64
共有 2 個檔案被更改,包括 6 行新增 和 1 行删除
+2 -1
查看文件
@@ -361,7 +361,8 @@ bool PlatformState::getTexRef(const char* hostVar, hipModule_t hmod, textureRefe
return false;
}
*texRef = reinterpret_cast<textureReference *>(dvar->shadowVptr);
*texRef = new (dvar->shadowVptr) texture<char>{};
return true;
}