Buffer access fixes

This commit is contained in:
Jack Andersen 2015-09-09 14:08:29 -10:00
parent 83252ea611
commit 23f89ee747
3 changed files with 12 additions and 5 deletions

View File

@ -188,10 +188,14 @@ class DLReader
{ {
case GX::DIRECT: case GX::DIRECT:
case GX::INDEX8: case GX::INDEX8:
if ((m_cur - m_dl.get()) >= intptr_t(m_dlSize))
return 0;
retval = *m_cur; retval = *m_cur;
++m_cur; ++m_cur;
break; break;
case GX::INDEX16: case GX::INDEX16:
if ((m_cur - m_dl.get() + 1) >= intptr_t(m_dlSize))
return 0;
retval = HECL::SBig(*(atUint16*)m_cur); retval = HECL::SBig(*(atUint16*)m_cur);
m_cur += 2; m_cur += 2;
break; break;
@ -207,7 +211,7 @@ public:
} }
operator bool() operator bool()
{ {
return *m_cur && ((m_cur - m_dl.get()) < intptr_t(m_dlSize)); return ((m_cur - m_dl.get()) < intptr_t(m_dlSize)) && *m_cur;
} }
GX::Primitive readPrimitive() GX::Primitive readPrimitive()
{ {
@ -215,7 +219,9 @@ public:
} }
atUint16 readVertCount() atUint16 readVertCount()
{ {
return readVal(GX::INDEX16); atUint16 retval = HECL::SBig(*(atUint16*)m_cur);
m_cur += 2;
return retval;
} }
struct DLPrimVert struct DLPrimVert
{ {

View File

@ -348,9 +348,10 @@ public:
if (extractor.weight != w) if (extractor.weight != w)
continue; continue;
HECL::SystemStringView bestName(getBestEntryName(*item.second)); std::string bestName = getBestEntryName(*item.second);
HECL::SystemStringView bestNameView(bestName);
float thisFac = ++count / fsz; float thisFac = ++count / fsz;
progress(bestName.sys_str().c_str(), thisFac); progress(bestNameView.sys_str().c_str(), thisFac);
HECL::ProjectPath cooked = getCooked(item.second); HECL::ProjectPath cooked = getCooked(item.second);
if (force || cooked.getPathType() == HECL::ProjectPath::PT_NONE) if (force || cooked.getPathType() == HECL::ProjectPath::PT_NONE)

2
hecl

@ -1 +1 @@
Subproject commit 168429814320c39b063cfee37c85261dc01c3305 Subproject commit 0935dad69fb8ac18556d280b9886aad11fafec78