diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-03-05 16:39:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-03-09 00:30:07 +0100 |
| commit | 85e98d35160535141ba3a601900fcb0cc19b54fe (patch) | |
| tree | 4a2ae6bf08d16489e51ae175b0729d124af2afee /src/lib | |
| parent | 431127d27fe697a60872d6020a8a5abcb47fa9e1 (diff) | |
Be more careful with some macOS API calls.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/cross_osx.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index 8f057c2bf..6c00afb97 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -275,7 +275,12 @@ get_vendor (CFDictionaryRef& description) return {}; } - string s = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8); + auto c_str = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8); + if (!c_str) { + return {}; + } + + string s (c_str); boost::algorithm::trim (s); return s; } @@ -288,7 +293,12 @@ get_model (CFDictionaryRef& description) return {}; } - string s = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8); + auto c_str = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8); + if (!c_str) { + return {}; + } + + string s (c_str); boost::algorithm::trim (s); return s; } @@ -415,6 +425,7 @@ disk_appeared (DADiskRef disk, void* context) { auto bsd_name = DADiskGetBSDName (disk); if (!bsd_name) { + LOG_DISK_NC("Disk with no BSDName appeared"); return; } LOG_DISK("%1 appeared", bsd_name); @@ -422,6 +433,7 @@ disk_appeared (DADiskRef disk, void* context) Disk this_disk; this_disk.mount_point = string("/dev/") + bsd_name; + LOG_DISK("Mount point is %1", this_disk.mount_point); CFDictionaryRef description = DADiskCopyDescription (disk); |
