Sanity check the return value from SBSCopyApplicationDisplayIdentifiers() before calling CFArrayGetCount() on it.

rdar://problem/11331867

llvm-svn: 156562
This commit is contained in:
Johnny Chen 2012-05-10 19:24:41 +00:00
parent 75812f815c
commit bbc00939f2
1 changed files with 2 additions and 1 deletions

View File

@ -36,7 +36,8 @@ ListApplications(std::string& plist, bool opt_runningApps, bool opt_debuggable)
CFReleaser<CFStringRef> sbsFrontAppID (::SBSCopyFrontmostApplicationDisplayIdentifier ());
CFReleaser<CFArrayRef> sbsAppIDs (::SBSCopyApplicationDisplayIdentifiers (opt_runningApps, opt_debuggable));
CFIndex count = ::CFArrayGetCount (sbsAppIDs.get());
// Need to check the return value from SBSCopyApplicationDisplayIdentifiers.
CFIndex count = sbsAppIDs.get() ? ::CFArrayGetCount (sbsAppIDs.get()) : 0;
CFIndex i = 0;
for (i = 0; i < count; i++)
{