Fix crash in IsSCAssem
The test for "is this an S-C Assembler source file" tried to dereference a null pointer when asked to examine a file with a zero-length data fork. The test only fires for files with type=INT and auxType=0, so this is pretty hard to hit. The specific failing case had a damaged file with the appropriate file type. Issue #42
This commit is contained in:
parent
a85ceca75f
commit
5e9d8f0102
|
@ -81,7 +81,11 @@ void ReformatSCAssem::Examine(ReformatHolder* pHolder)
|
||||||
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = *ptr;
|
if (srcLen < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = *ptr; // get length byte
|
||||||
if (len == 0 || len > srcLen)
|
if (len == 0 || len > srcLen)
|
||||||
return false; // should return an error, really
|
return false; // should return an error, really
|
||||||
if (ptr[len-1] == 0x00) {
|
if (ptr[len-1] == 0x00) {
|
||||||
|
|
|
@ -208,7 +208,7 @@ public:
|
||||||
for (i = 0; i < kReformatMAX; i++)
|
for (i = 0; i < kReformatMAX; i++)
|
||||||
fApplies[part][i] = kApplicUnknown;
|
fApplies[part][i] = kApplicUnknown;
|
||||||
fSourceBuf[part] = NULL;
|
fSourceBuf[part] = NULL;
|
||||||
fSourceLen[part] = NULL;
|
fSourceLen[part] = 0;
|
||||||
fErrorBuf[part] = NULL;
|
fErrorBuf[part] = NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < kReformatMAX; i++) {
|
for (i = 0; i < kReformatMAX; i++) {
|
||||||
|
@ -356,7 +356,7 @@ private:
|
||||||
char* fNameExt; // guaranteed non-NULL
|
char* fNameExt; // guaranteed non-NULL
|
||||||
|
|
||||||
/* input goes here */
|
/* input goes here */
|
||||||
uint8_t* fSourceBuf[kPartMAX];
|
uint8_t* fSourceBuf[kPartMAX];
|
||||||
long fSourceLen[kPartMAX];
|
long fSourceLen[kPartMAX];
|
||||||
|
|
||||||
char* fErrorBuf[kPartMAX];
|
char* fErrorBuf[kPartMAX];
|
||||||
|
|
|
@ -139,7 +139,7 @@ private:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Abstract base class for reformatting a graphics file into a
|
* Abstract base class for reformatting a graphics file into a
|
||||||
* device-independent bitmap..
|
* device-independent bitmap.
|
||||||
*/
|
*/
|
||||||
class ReformatGraphics: public Reformat {
|
class ReformatGraphics: public Reformat {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue