Skip to content

Commit fc3f219

Browse files
committed
Revert "xrRender/ShaderResourceTraits.h: removed excessive string duplication"
This reverts commit bba8744.
1 parent 46bc819 commit fc3f219

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Layers/xrRender/ShaderResourceTraits.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,18 @@ inline T* CResourceManager::CreateShader(const char* name, const char* filename
394394
}
395395
R_ASSERT3(file, "Shader file doesnt exist:", cname);
396396

397+
// Duplicate and zero-terminate
398+
const auto size = file->length();
399+
char* const data = (LPSTR)_alloca(size + 1);
400+
CopyMemory(data, file->pointer(), size);
401+
data[size] = 0;
402+
397403
// Select target
398404
LPCSTR c_target = ShaderTypeTraits<T>::GetCompilationTarget();
399405
LPCSTR c_entry = "main";
400406

401407
if (searchForEntryAndTarget)
402-
ShaderTypeTraits<T>::GetCompilationTarget(c_target, c_entry, static_cast<pcstr>(file->pointer()));
408+
ShaderTypeTraits<T>::GetCompilationTarget(c_target, c_entry, data);
403409

404410
#ifdef USE_OGL
405411
DWORD flags = NULL;

0 commit comments

Comments
 (0)