Author: geechorama
Date: Thu Jul 23 18:12:18 2009
New Revision: 797175
URL: http://svn.apache.org/viewvc?rev=797175&view=rev
Log:
THRIFT-548. malloc our temporary buffer, rather than creating it on the stack.
Modified:
incubator/thrift/trunk/lib/cocoa/src/protocol/TBinaryProtocol.m
Modified: incubator/thrift/trunk/lib/cocoa/src/protocol/TBinaryProtocol.m
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/cocoa/src/protocol/TBinaryProtocol.m?rev=797175&r1=797174&r2=797175&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/cocoa/src/protocol/TBinaryProtocol.m (original)
+++ incubator/thrift/trunk/lib/cocoa/src/protocol/TBinaryProtocol.m Thu Jul 23
18:12:18 2009
@@ -90,10 +90,18 @@
- (NSString *) readStringBody: (int) size
{
- char buff[size+1];
- [mTransport readAll: (uint8_t *) buff offset: 0 length: size];
- buff[size] = 0;
- return [NSString stringWithUTF8String: buff];
+ char * buffer = malloc(size+1);
+ if (!buffer) {
+ @throw [TProtocolException exceptionWithName: @"TProtocolException"
+ reason: [NSString stringWithFormat:
@"Unable to allocate memory in %s, size: %i",
+ __PRETTY_FUNCTION__,
+ size]];;
+ }
+ [mTransport readAll: (uint8_t *) buffer offset: 0 length: size];
+ buffer[size] = 0;
+ NSString * result = [NSString stringWithUTF8String: buffer];
+ free(buffer);
+ return result;
}