Issue #370: Fix problem where stream errors would not be detected
It seems the comparison has always been against the wrong enum, so the check would never trigger previously. The latest llvm issues a warning like this: ASIDataDecompressor.m:161:34: Comparison of constant 'NSStreamEventErrorOccurred' (8) with expression of type 'NSStreamStatus' (aka 'enum NSStreamStatus') is always false [patch from github user 'OpenFibers', thanks!]
Showing
2 changed files
with
4 additions
and
4 deletions
@@ -161,7 +161,7 @@ | @@ -161,7 +161,7 @@ | ||
161 | readLength = [inputStream read:inputData maxLength:DATA_CHUNK_SIZE]; | 161 | readLength = [inputStream read:inputData maxLength:DATA_CHUNK_SIZE]; |
162 | 162 | ||
163 | // Make sure nothing went wrong | 163 | // Make sure nothing went wrong |
164 | - if ([inputStream streamStatus] == NSStreamEventErrorOccurred) { | 164 | + if ([inputStream streamStatus] == NSStreamStatusError) { |
165 | if (err) { | 165 | if (err) { |
166 | *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to read from the source data file",sourcePath],NSLocalizedDescriptionKey,[inputStream streamError],NSUnderlyingErrorKey,nil]]; | 166 | *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to read from the source data file",sourcePath],NSLocalizedDescriptionKey,[inputStream streamError],NSUnderlyingErrorKey,nil]]; |
167 | } | 167 | } |
@@ -187,7 +187,7 @@ | @@ -187,7 +187,7 @@ | ||
187 | [outputStream write:(const uint8_t *)[outputData bytes] maxLength:[outputData length]]; | 187 | [outputStream write:(const uint8_t *)[outputData bytes] maxLength:[outputData length]]; |
188 | 188 | ||
189 | // Make sure nothing went wrong | 189 | // Make sure nothing went wrong |
190 | - if ([inputStream streamStatus] == NSStreamEventErrorOccurred) { | 190 | + if ([inputStream streamStatus] == NSStreamStatusError) { |
191 | if (err) { | 191 | if (err) { |
192 | *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to write to the destination data file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]]; | 192 | *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to write to the destination data file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]]; |
193 | } | 193 | } |
@@ -158,7 +158,7 @@ | @@ -158,7 +158,7 @@ | ||
158 | readLength = [inputStream read:inputData maxLength:DATA_CHUNK_SIZE]; | 158 | readLength = [inputStream read:inputData maxLength:DATA_CHUNK_SIZE]; |
159 | 159 | ||
160 | // Make sure nothing went wrong | 160 | // Make sure nothing went wrong |
161 | - if ([inputStream streamStatus] == NSStreamEventErrorOccurred) { | 161 | + if ([inputStream streamStatus] == NSStreamStatusError) { |
162 | if (err) { | 162 | if (err) { |
163 | *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to read from the source data file",sourcePath],NSLocalizedDescriptionKey,[inputStream streamError],NSUnderlyingErrorKey,nil]]; | 163 | *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to read from the source data file",sourcePath],NSLocalizedDescriptionKey,[inputStream streamError],NSUnderlyingErrorKey,nil]]; |
164 | } | 164 | } |
@@ -184,7 +184,7 @@ | @@ -184,7 +184,7 @@ | ||
184 | [outputStream write:(Bytef*)[outputData bytes] maxLength:[outputData length]]; | 184 | [outputStream write:(Bytef*)[outputData bytes] maxLength:[outputData length]]; |
185 | 185 | ||
186 | // Make sure nothing went wrong | 186 | // Make sure nothing went wrong |
187 | - if ([inputStream streamStatus] == NSStreamEventErrorOccurred) { | 187 | + if ([inputStream streamStatus] == NSStreamStatusError) { |
188 | if (err) { | 188 | if (err) { |
189 | *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to write to the destination data file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]]; | 189 | *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to write to the destination data file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]]; |
190 | } | 190 | } |
-
Please register or login to post a comment