Commits

Bill Garrison committed d982ba7

Sorted out potential memory leak issues flagged by clang.

Comments (0)

Files changed (1)

NSURL+SOExtendedAttributes.m

         }
         
         /* No names? Bail now with empty list. */
-        if (bufferSize == 0) return attributeNames;
+        if (bufferSize == 0)
+        {
+            if (namesBuffer) free(namesBuffer);
+            return attributeNames;
+        }
         
         /* Problemo? Bail now with the POSIX error. */
         if (bufferSize == -1)
         {
+            if (namesBuffer) free(namesBuffer);
+
             attributeNames = nil;
             if (outError) *outError = SOPOSIXErrorForURL(self);
             return nil;
     return YES;
 }
 
-#pragma mark -
-#pragma mark Individual Attributes
+#pragma mark - Individual Attributes
 
 - (BOOL) hasExtendedAttributeWithName:(NSString *)name
 {
         if (dataSize == -1)
         {
             if (outError) *outError = SOPOSIXErrorForURL(self);
+            if (buffer) {
+                free(buffer); buffer = NULL;
+            }
             
         } else {
             
             NSData *data = [NSData dataWithBytesNoCopy:buffer length:dataSize freeWhenDone:YES];
             retrievedValue = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:NULL error:outError];
         }
+        
+
     }
     
     return retrievedValue;