Differences From Artifact [4455805b29]:
- File src/OFString+URLEncoding.m — part of check-in [c7f0229795] at 2020-01-02 01:51:34 on branch trunk — Update copyright (user: js, size: 3606) [annotate] [blame] [check-ins using] [more...]
To Artifact [329955234f]:
- File
src/OFString+URLEncoding.m
— part of check-in
[a2b4238850]
at
2020-11-06 02:24:14
on branch trunk
— Future-proof some code using freeWhenDone
While -[OFData initWithDataNoCopy:count:itemSize:freeWhenDone:] can
currently never throw, it might in the future, and when it does so in
the future, these would be memory leaks then. (user: js, size: 3584) [annotate] [blame] [check-ins using] [more...]
| ︙ | ︙ | |||
80 81 82 83 84 85 86 |
}
- (OFString *)stringByURLDecoding
{
void *pool = objc_autoreleasePoolPush();
const char *string = self.UTF8String;
size_t length = self.UTF8StringLength;
| | | < < | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
}
- (OFString *)stringByURLDecoding
{
void *pool = objc_autoreleasePoolPush();
const char *string = self.UTF8String;
size_t length = self.UTF8StringLength;
char *retCString;
char byte = 0;
int state = 0;
size_t i = 0;
retCString = of_malloc(length + 1, 1);
while (length--) {
char c = *string++;
switch (state) {
case 0:
if (c == '%')
|
| ︙ | ︙ | |||
132 133 134 135 136 137 138 |
objc_autoreleasePoolPop(pool);
if (state != 0) {
free(retCString);
@throw [OFInvalidFormatException exception];
}
| > > > | < < | > > | | | > > > | > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
objc_autoreleasePoolPop(pool);
if (state != 0) {
free(retCString);
@throw [OFInvalidFormatException exception];
}
@try {
retCString = of_realloc(retCString, 1, i + 1);
} @catch (OFOutOfMemoryException *e) {
/* We don't care if it fails, as we only made it smaller. */
}
@try {
return [OFString stringWithUTF8StringNoCopy: retCString
length: i
freeWhenDone: true];
} @catch (id e) {
free(retCString);
@throw e;
}
}
@end
|