diff options
| author | Hubert Maier | 2019-10-07 23:15:29 +0200 | 
|---|---|---|
| committer | Filippos Karapetis | 2019-10-08 11:32:30 +0300 | 
| commit | bfc296bc4b8e6f01e471984458fa66ad5acc2a1e (patch) | |
| tree | 19f6340a9fa0f7e652ea34e925938396cdf51033 /backends/fs | |
| parent | 4620843f2791b94391791dc3e43b94743892de26 (diff) | |
| download | scummvm-rg350-bfc296bc4b8e6f01e471984458fa66ad5acc2a1e.tar.gz scummvm-rg350-bfc296bc4b8e6f01e471984458fa66ad5acc2a1e.tar.bz2 scummvm-rg350-bfc296bc4b8e6f01e471984458fa66ad5acc2a1e.zip  | |
AMIGAOS4: Fix NULL access
Diffstat (limited to 'backends/fs')
| -rw-r--r-- | backends/fs/amigaos4/amigaos4-fs.cpp | 61 | 
1 files changed, 37 insertions, 24 deletions
diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index 3561303b6d..624f8aaa25 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -62,13 +62,21 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode() {  	_bIsDirectory = true;  	_sPath = "";  	_pFileLock = 0; -	_nProt = 0; // Protection is ignored for the root volume +	_nProt = 0; // Protection is ignored for the root volume.  	LEAVE();  }  AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) {  	ENTER(); +	// We need to explicitely open dos.library and it's IDOS interface. +	// Otherwise we'll hit an IDOS NULL pointer after compiling a shared +	// binary with (shared) plugins. +	// The hit will happen on loading a game from any engine, if more +	// than one engine/plugin is available. +	DOSBase=IExec->OpenLibrary("dos.library",0); +	IDOS = (struct DOSIFace *)IExec->GetInterface(DOSBase, "main", 1, NULL); +	  	int offset = p.size();  	//assert(offset > 0); @@ -84,7 +92,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) {  	_bIsDirectory = false;  	_bIsValid = false; -	// Check whether the node exists and if it's a directory +	// Check whether the node exists and if it's a directory.  	struct ExamineData * pExd = IDOS->ExamineObjectTags(EX_StringNameInput,_sPath.c_str(),TAG_END);  	if (pExd) {  		_nProt = pExd->Protection; @@ -93,7 +101,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) {  			_pFileLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK);  			_bIsValid = (_pFileLock != 0); -			// Add a trailing slash if needed +			// Add a trailing slash if needed.  			const char c = _sPath.lastChar();  			if (c != '/' && c != ':')  				_sPath += '/'; @@ -105,6 +113,10 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) {  		IDOS->FreeDosObject(DOS_EXAMINEDATA, pExd);  	} +	// Close dos.library and it's IDOS interface again. +	IExec->DropInterface((struct Interface *)IDOS); +	IExec->CloseLibrary(DOSBase); +  	LEAVE();  } @@ -161,7 +173,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam  	LEAVE();  } -// We need the custom copy constructor because of DupLock() +// We need the custom copy constructor because of DupLock().  AmigaOSFilesystemNode::AmigaOSFilesystemNode(const AmigaOSFilesystemNode& node)  : AbstractFSNode() {  	ENTER(); @@ -237,9 +249,6 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b  	ENTER();  	bool ret = false; -	// TODO: Honor the hidden flag -	// There is no such thing as a hidden flag in AmigaOS... -  	if (!_bIsValid) {  		debug(6, "Invalid node");  		LEAVE(); @@ -343,9 +352,9 @@ bool AmigaOSFilesystemNode::isReadable() const {  	if (!_bIsValid)  		return false; -	// Regular RWED protection flags are low-active or inverted, thus the negation. -	// Moreover, a pseudo root filesystem is readable whatever the -	// protection says. +	// Regular RWED protection flags are low-active or inverted, +	// thus the negation. Moreover, a pseudo root filesystem is +	// readable whatever the protection says.  	bool readable = !(_nProt & EXDF_OTR_READ) || isRootNode();  	return readable; @@ -355,9 +364,10 @@ bool AmigaOSFilesystemNode::isWritable() const {  	if (!_bIsValid)  		return false; -	// Regular RWED protection flags are low-active or inverted, thus the negation. -	// Moreover, a pseudo root filesystem is never writable whatever -	// the protection says (Because of it's pseudo nature). +	// Regular RWED protection flags are low-active or inverted, +	// thus the negation. Moreover, a pseudo root filesystem is +	// never writable whatever the protection says. +	// (Because of it's pseudo nature).  	bool writable = !(_nProt & EXDF_OTR_WRITE) && !isRootNode();  	return writable; @@ -385,18 +395,21 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const {  			dosList->dol_Port) {  			// The original line was -			//if (dosList->dol_Type == DLT_VOLUME && -			//dosList->dol_Name && -			//dosList->dol_Task) { -			// which errored using SDK 53.24 with a 'struct dosList' has no member called 'dol_Task' -			// The reason for that was that -			// 1) dol_Task wasn't a task pointer, it is a message port instead -			// 2) It was redefined to be dol_Port in dos/obsolete.h in afore mentioned SDK - -			// Copy name to buffer +			// +			//	if (dosList->dol_Type == DLT_VOLUME && +			//		dosList->dol_Name && +			//		dosList->dol_Task) { +			// +			// which errored using SDK 53.24 with a +			//	'struct dosList' has no member called 'dol_Task' +			// The reason for that was, that +			//	1) dol_Task wasn't a task pointer, it is a message port instead. +			//	2) it was redefined to be dol_Port in dos/obsolete.h in aforementioned SDK. + +			// Copy name to buffer.  			IDOS->CopyStringBSTRToC(dosList->dol_Name, buffer, MAXPATHLEN); -			// Volume name + '\0' +			// Volume name + '\0'.  			char *volName = new char [strlen(buffer) + 1];  			strcpy(volName, buffer); @@ -408,7 +421,7 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const {  				char *devName = new char [MAXPATHLEN]; -				// Find device name +				// Find device name.  				IDOS->DevNameFromLock(volumeLock, devName, MAXPATHLEN, DN_DEVICEONLY);  				sprintf(buffer, "%s (%s)", volName, devName);  | 
