Overview
| Comment: | Key Value Coding: Make sure free is always called
In theory, if -[UTF8String] would throw, this could leak. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
49ed0fa5ec301f4a1120f2e848734868 |
| User & Date: | js on 2016-06-05 16:04:11 |
| Other Links: | manifest | tags |
Context
|
2016-06-05
| ||
| 17:28 | Update Xcode project to recent changes (check-in: 111c2e14b8 user: js tags: trunk) | |
| 16:04 | Key Value Coding: Make sure free is always called (check-in: 49ed0fa5ec user: js tags: trunk) | |
| 16:00 | Key Value Coding: Add fallback to isFoo (check-in: 10fbb20fd6 user: js tags: trunk) | |
Changes
Modified src/OFObject+KeyValueCoding.m from [f4fafd457a] to [6d4c66aa16].
| ︙ | ︙ | |||
55 56 57 58 59 60 61 | if ((keyLength = [key UTF8StringLength]) < 1) return [self valueForUndefinedKey: key]; if ((name = malloc(keyLength + 3)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: keyLength + 3]; | > | | | | | | | > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
if ((keyLength = [key UTF8StringLength]) < 1)
return [self valueForUndefinedKey: key];
if ((name = malloc(keyLength + 3)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithRequestedSize: keyLength + 3];
@try {
memcpy(name, "is", 2);
memcpy(name + 2, [key UTF8String], keyLength);
name[keyLength + 2] = '\0';
name[2] = toupper(name[2]);
selector = sel_registerName(name);
} @finally {
free(name);
}
typeEncoding = [self typeEncodingForSelector: selector];
if (typeEncoding == NULL ||
*typeEncoding == '@' || *typeEncoding == '#')
return [self valueForUndefinedKey: key];
}
|
| ︙ | ︙ | |||
135 136 137 138 139 140 141 | return; } if ((name = malloc(keyLength + 5)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: keyLength + 5]; | > | | | | | | | > | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
return;
}
if ((name = malloc(keyLength + 5)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithRequestedSize: keyLength + 5];
@try {
memcpy(name, "set", 3);
memcpy(name + 3, [key UTF8String], keyLength);
memcpy(name + keyLength + 3, ":", 2);
name[3] = toupper(name[3]);
selector = sel_registerName(name);
} @finally {
free(name);
}
typeEncoding = [self typeEncodingForSelector: selector];
if (typeEncoding == NULL || nextType(&typeEncoding) != 'v' ||
nextType(&typeEncoding) != '@' || nextType(&typeEncoding) != ':') {
[self setValue: value
forUndefinedKey: key];
|
| ︙ | ︙ |