pombreda / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

SHConstructCompiler crash prevention #446

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Calling SHConstructCompiler with the wrong output will cause a crash.  This is 
caused because ConstructCompiler in CodeGenHLSL.cpp or CodeGenGLSL.cpp return 
NULL, which is dereferenced in line 151 of ShaderLang.cpp.  I suggest a check 
for NULL be added.

Current code (ShaderLang.cpp lines 151-154)
    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec, output));
    TCompiler* compiler = base->getAsCompiler();
    if (compiler == 0)
        return 0;

Suggested replacement which prevents the crash and behaves correctly:
    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec, output));
    if (base == 0)
        return 0;
    TCompiler* compiler = base->getAsCompiler();
    if (compiler == 0)
        return 0;

Original issue reported on code.google.com by achriste...@gmail.com on 10 Jul 2013 at 6:50

GoogleCodeExporter commented 9 years ago
I'll take a look.

Original comment by z...@google.com on 12 Jul 2013 at 8:35