summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-01-16 15:34:08 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-02-04 10:46:37 +0100
commit5602ba2f07a893604ea0506b3d580d4f2e2999ae (patch)
treea5ccb8a125d4718fb8fbbd435ec32db58a77ba70
parentb9bf66e67ed1d0d1b1d3163255cab099a6ba4a95 (diff)
downloadqtlocation-mapboxgl-5602ba2f07a893604ea0506b3d580d4f2e2999ae.tar.gz
do not leak string handles
-rw-r--r--platform/darwin/string_nsstring.mm14
1 files changed, 10 insertions, 4 deletions
diff --git a/platform/darwin/string_nsstring.mm b/platform/darwin/string_nsstring.mm
index 9b1dc745cb..ef6b96062a 100644
--- a/platform/darwin/string_nsstring.mm
+++ b/platform/darwin/string_nsstring.mm
@@ -7,14 +7,20 @@ namespace platform {
std::string uppercase(const std::string &string) {
NSString *nsstring = [[NSString alloc] initWithBytesNoCopy:const_cast<char *>(string.data()) length:string.size() encoding:NSUTF8StringEncoding freeWhenDone:NO];
- nsstring = [nsstring uppercaseString];
- return { [nsstring cStringUsingEncoding:NSUTF8StringEncoding], [nsstring lengthOfBytesUsingEncoding:NSUTF8StringEncoding] };
+ NSString *nsstring2 = [nsstring uppercaseString];
+ [nsstring release];
+ const std::string result { [nsstring2 cStringUsingEncoding:NSUTF8StringEncoding], [nsstring2 lengthOfBytesUsingEncoding:NSUTF8StringEncoding] };
+ [nsstring2 release];
+ return result;
}
std::string lowercase(const std::string &string) {
NSString *nsstring = [[NSString alloc] initWithBytesNoCopy:const_cast<char *>(string.data()) length:string.size() encoding:NSUTF8StringEncoding freeWhenDone:NO];
- nsstring = [nsstring lowercaseString];
- return { [nsstring cStringUsingEncoding:NSUTF8StringEncoding], [nsstring lengthOfBytesUsingEncoding:NSUTF8StringEncoding] };
+ NSString *nsstring2 = [nsstring lowercaseString];
+ [nsstring release];
+ const std::string result { [nsstring2 cStringUsingEncoding:NSUTF8StringEncoding], [nsstring2 lengthOfBytesUsingEncoding:NSUTF8StringEncoding] };
+ [nsstring2 release];
+ return result;
}
}