From 5a9d80944b4267da41878999ab0d0eafdf2ac97b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 19 Feb 2010 23:27:28 -0500 Subject: [PATCH] Fix encoding issues by not implicit casting UInt8 to char. Go through CFString instead. --- Source/GDBpConnection.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/GDBpConnection.m b/Source/GDBpConnection.m index fb1243b..329e052 100644 --- a/Source/GDBpConnection.m +++ b/Source/GDBpConnection.m @@ -488,8 +488,14 @@ void SocketAcceptCallback(CFSocketRef socket, // We haven't finished reading a packet, so just read more data in. if (currentPacketIndex_ < packetSize_) { - [currentPacket_ appendFormat:@"%s", buffer]; currentPacketIndex_ += bytesRead; + CFStringRef bufferString = CFStringCreateWithBytes(kCFAllocatorDefault, + buffer, + bytesRead, + kCFStringEncodingUTF8, + true); + [self.currentPacket appendString:(NSString*)bufferString]; + CFRelease(bufferString); } // Time to read a new packet. else @@ -497,7 +503,13 @@ void SocketAcceptCallback(CFSocketRef socket, // Read the message header: the size. packetSize_ = atoi(charBuffer); currentPacketIndex_ = bytesRead - strlen(charBuffer); - self.currentPacket = [NSMutableString stringWithFormat:@"%s", buffer + strlen(charBuffer) + 1]; + CFStringRef bufferString = CFStringCreateWithBytes(kCFAllocatorDefault, + buffer + strlen(charBuffer) + 1, + bytesRead - strlen(charBuffer) - 1, + kCFStringEncodingUTF8, + true); + self.currentPacket = [NSMutableString stringWithString:(NSString*)bufferString]; + CFRelease(bufferString); } // We have finished reading the packet. -- 2.43.5