]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_mds/lib/MDSDictionary.cpp
Security-59306.61.1.tar.gz
[apple/security.git] / OSX / libsecurity_mds / lib / MDSDictionary.cpp
index 604e040331aa7dbcffed0c86836daae7e9550b51..4e330e97f506b9212eaa10e86e46f659236674ed 100644 (file)
@@ -384,13 +384,10 @@ void MDSDictionary::lookupAttributes(
  *             }
  *             ...else return error;
  */
-const CFPropertyListRef MDSDictionary::lookupWithIndirect(
+CFPropertyListRef MDSDictionary::lookupWithIndirect(
        const char *key,
        CFBundleRef bundle,
-       CFTypeID        desiredType,
-       bool            &fetchedFromDisk)       // true --> caller must CFRelease the returned
-                                                                       //     value
-                                                                       // false -> it's part of this dictionary
+       CFTypeID        desiredType)
 {
        CFPropertyListRef ourRtn = NULL;
        CFDataRef dictData = NULL;
@@ -402,8 +399,6 @@ const CFPropertyListRef MDSDictionary::lookupWithIndirect(
        assert(key != NULL);
        assert(bundle != NULL);
        
-       fetchedFromDisk = false;
-       
        /* basic local lookup */
        CFStringRef cfKey = CFStringCreateWithCString(NULL,
                key,
@@ -412,22 +407,22 @@ const CFPropertyListRef MDSDictionary::lookupWithIndirect(
                MPDebug("CFStringCreateWithCString error");
                return NULL;
        }
-       const void *rtn = CFDictionaryGetValue(mDict, cfKey);
+       CFCopyRef<CFStringRef> rtn = (CFStringRef)CFDictionaryGetValue(mDict, cfKey);
        CFRelease(cfKey);
-       if(rtn == NULL) {
+       if(!rtn) {
                return NULL;
        }
-       CFTypeID foundType = CFGetTypeID((CFTypeRef)rtn);
+       CFTypeID foundType = CFGetTypeID(rtn);
        if(foundType == desiredType) {
                /* found what we're looking for; done */
-               return (CFPropertyListRef)rtn;
+               return (CFPropertyListRef)rtn.yield();
        }
        
        /* is it a string which starts with "file:"? */
        if(foundType != CFStringGetTypeID()) {
                return NULL;
        }
-       const char *cVal = MDSCFStringToCString((CFStringRef)rtn);
+       const char *cVal = MDSCFStringToCString(rtn);
        if(cVal == NULL) {
                MPDebug("MDSCFStringToCString error in lookupWithIndirect");
                return NULL;
@@ -490,8 +485,7 @@ const CFPropertyListRef MDSDictionary::lookupWithIndirect(
        }
 
        MPDebug("lookupWithIndirect: resource %s FOUND", cVal);
-       fetchedFromDisk = true;
-       
+
 abort:
        delete [] cVal;
        CF_RELEASE(cfFileName);