diff options
author | david.switzer <daveswitzer@monoclesociety.com> | 2017-03-02 14:54:58 -0800 |
---|---|---|
committer | david.switzer <daveswitzer@monoclesociety.com> | 2017-03-03 14:55:21 -0800 |
commit | 6c19de268769c2269c4133f6845e18f5b0f93442 (patch) | |
tree | 516787fa99cd82911b0fcfc1e88ff8f011201ae4 | |
parent | 708f085f5e3e976f0019e768e0cf5631b4575432 (diff) | |
download | sdl_ios-6c19de268769c2269c4133f6845e18f5b0f93442.tar.gz |
Prevent infinite loops in send block while by checking ostream state.
-rw-r--r-- | SmartDeviceLink/SDLIAPTransport.m | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m index 5cf4ceb21..1a4d8a7e2 100644 --- a/SmartDeviceLink/SDLIAPTransport.m +++ b/SmartDeviceLink/SDLIAPTransport.m @@ -272,8 +272,9 @@ int const streamOpenTimeoutSeconds = 2; NSOutputStream *ostream = self.session.easession.outputStream; NSMutableData *remainder = data.mutableCopy; - while (remainder.length != 0) { - if (ostream.streamStatus == NSStreamStatusOpen && ostream.hasSpaceAvailable) { + while (ostream.streamStatus == NSStreamStatusOpen && + remainder.length != 0) { + if (ostream.hasSpaceAvailable){ NSInteger bytesWritten = [ostream write:remainder.bytes maxLength:remainder.length]; if (bytesWritten == -1) { |