From 7aae31db39c48ff5803a02086340d663179b4d38 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Sat, 21 Nov 2009 17:24:16 +0000 Subject: [PATCH] Stop the crash in cdvd detection when system.cnf is too big. Probably not the best way to implement it but it should work. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2232 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD/CDVDaccess.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index e4b592fddb..100e463e9e 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -31,6 +31,7 @@ #include "IsoFS/IsoFS.h" #include "IsoFS/IsoFSCDVD.h" #include "CDVDisoReader.h" +#include "Utilities/ScopedPtr.h" const wxChar* CDVD_SourceLabels[] = { @@ -77,14 +78,14 @@ static int CheckDiskTypeFS(int baseType) int size = file.getLength(); - char buffer[256]; //if the file is longer...it should be shorter :D - file.read((u8*)buffer,size); + ScopedArray buffer((int)file.getLength()+1); + file.read((u8*)(buffer.GetPtr()),size); buffer[size]='\0'; - char* pos = strstr(buffer, "BOOT2"); + char* pos = strstr(buffer.GetPtr(), "BOOT2"); if (pos == NULL) { - pos = strstr(buffer, "BOOT"); + pos = strstr(buffer.GetPtr(), "BOOT"); if (pos == NULL) return CDVD_TYPE_ILLEGAL; return CDVD_TYPE_PSCD; }