Commits

Bill Garrison committed f93b834

Fixed bug where attempting to return an NSError by reference without checking validity of the error parameter.

  • Participants
  • Parent commits 4ee2994

Comments (0)

Files changed (2)

NSURL+SOExtendedAttributes.h

-
 /*
  NSURL+SOExtendedAttributes
  
  License at the bottom of the file.
  */
 
+#import <Foundation/Foundation.h>
+#import <Availability.h>
+
+#if TARGET_OS_IPHONE
+#ifndef __IPHONE_5_0
+#warning "This project uses features only available in iOS SDK 5.0 and later."
+#endif
+#elif TARGET_OS_MAC
+#ifndef __MAC_10_7
+#warning "This project uses features only available in Mac OS X SDK 10.7 and later."
+#endif
+#endif
+
 /**
  The SOExtendedAttributes category on NSURL enables retrieving and manipulating the extended attributes on a file system item.
  
     SOExtendedAttributesGetValueError,
 };
 
-#import <Foundation/Foundation.h>
 
 @interface NSURL (SOExtendedAttributes)
 

NSURL+SOExtendedAttributes.m

         if (bufferSize == -1) 
         {
             attributeNames = nil;
-            *outError = SOPOSIXErrorForURL(self);
+           if (outError) *outError = SOPOSIXErrorForURL(self);
             return nil;
         }
         
     }
     else
     {
-        NSMutableDictionary *errInfo = [NSMutableDictionary dictionary];
-        [errInfo setObject:[NSString stringWithFormat:@"Value of class %@ cannot be serialized into a plist", NSStringFromClass([value class])] forKey:NSLocalizedDescriptionKey];
-        [errInfo setObject:value forKey:@"value"];
-        *outError = [NSError errorWithDomain:SOExtendedAttributesErrorDomain code:SOExtendedAttributesValueCantBeSerialized userInfo:errInfo];
+        if (outError)
+        {
+            NSMutableDictionary *errInfo = [NSMutableDictionary dictionary];
+            [errInfo setObject:[NSString stringWithFormat:@"Value of class %@ cannot be serialized into a plist", NSStringFromClass([value class])] forKey:NSLocalizedDescriptionKey];
+            [errInfo setObject:value forKey:@"value"];
+            *outError = [NSError errorWithDomain:SOExtendedAttributesErrorDomain code:SOExtendedAttributesValueCantBeSerialized userInfo:errInfo];
+        }
         return NO;
     }