From 4a98605123cc456ac7cac5260dd8b7d4a397846d Mon Sep 17 00:00:00 2001 From: ksherlock Date: Sat, 22 May 2010 16:10:59 +0000 Subject: [PATCH] fix null string error git-svn-id: https://profuse.googlecode.com/svn/branches/v2@258 aa027e90-d47c-11dd-86d7-074df07e0730 --- Device/BlockDevice.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Device/BlockDevice.cpp b/Device/BlockDevice.cpp index 4a326b1..e583165 100644 --- a/Device/BlockDevice.cpp +++ b/Device/BlockDevice.cpp @@ -34,6 +34,13 @@ unsigned BlockDevice::ImageType(const char *type, unsigned defv) if (type == 0 || *type == 0) return defv; + // type could be a path, eg images/file, disk.images/file + + // unix-specifix. + // basename alters the input string + tmp = std::strrchr(type, '/'); + if (tmp) type = tmp + 1; + // type could be a filename, in which case we check the extension. tmp = std::strrchr(type, '.'); if (tmp) type = tmp + 1; @@ -65,7 +72,7 @@ unsigned BlockDevice::ImageType(const char *type, unsigned defv) // not supported yet. - if (::strcasecmp(tmp, "sdk") == 0) + if (::strcasecmp(type, "sdk") == 0) return 'SDK_'; return defv;