aboutsummaryrefslogtreecommitdiff
path: root/backends/audiocd/macosx
diff options
context:
space:
mode:
authorJohannes Schickel2016-03-15 14:13:45 +0100
committerJohannes Schickel2016-03-15 14:24:23 +0100
commitad678cf083430e92729ede882fcfa2ff0fa5a2b0 (patch)
treec1738ce22e8cefb169d38de5541a8be28391dc26 /backends/audiocd/macosx
parent6a127df564a9e02d154b8e8f6e930896e7199349 (diff)
downloadscummvm-rg350-ad678cf083430e92729ede882fcfa2ff0fa5a2b0.tar.gz
scummvm-rg350-ad678cf083430e92729ede882fcfa2ff0fa5a2b0.tar.bz2
scummvm-rg350-ad678cf083430e92729ede882fcfa2ff0fa5a2b0.zip
MACOSX: Replace manual uint parsing by strtol.
Diffstat (limited to 'backends/audiocd/macosx')
-rw-r--r--backends/audiocd/macosx/macosx-audiocd.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/backends/audiocd/macosx/macosx-audiocd.cpp b/backends/audiocd/macosx/macosx-audiocd.cpp
index ef5b4c453a..56075f2a60 100644
--- a/backends/audiocd/macosx/macosx-audiocd.cpp
+++ b/backends/audiocd/macosx/macosx-audiocd.cpp
@@ -44,6 +44,7 @@
#include <sys/stat.h>
#include <sys/mount.h>
+#include <limits.h>
#include "common/scummsys.h"
@@ -274,15 +275,20 @@ bool MacOSXAudioCDManager::findTrackNames(const Common::String &drivePath) {
Common::String fileName = children[i].getName();
if (fileName.hasSuffix(".aiff") || fileName.hasSuffix(".cdda")) {
- uint trackID = 0, j = 0;
+ uint j = 0;
for (; j < fileName.size() && !Common::isDigit(fileName[j]); j++)
;
- for (; j < fileName.size() && Common::isDigit(fileName[j]); j++)
- trackID = trackID * 10 + (fileName[j] - '0');
+ const char *trackIDString = fileName.c_str() + j;
+ char *endPtr = nullptr;
+ long trackID = strtol(trackIDString, &endPtr, 10);
- _trackMap[trackID - 1] = drivePath + '/' + fileName;
+ if (trackIDString != endPtr && trackID > 0 && trackID < UINT_MAX) {
+ _trackMap[trackID - 1] = drivePath + '/' + fileName;
+ } else {
+ warning("Invalid track file name: '%s'", fileName.c_str());
+ }
}
}
}