Skip to content

Commit

Permalink
fix(ios): handle Ti.Stream.write with length 0 or empty buffer as suc…
Browse files Browse the repository at this point in the history
…cess no-op
  • Loading branch information
sgtcoolguy committed Jul 16, 2020
1 parent 0f94421 commit b58349d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions iphone/Classes/StreamModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ - (void)invokeRWOperation:(SEL)operation withArgs:(id)args
lengthValue = [[buffer data] length];
}

if (lengthValue == 0) {
// NO-OP
NSMutableDictionary *event = [TiUtils dictionaryWithCode:0 message:nil];
if (stream != nil) {
[event setObject:stream forKey:@"source"];
}
[event setObject:NUMINT(0) forKey:@"bytesProcessed"];
[self _fireEventToListener:@"io" withObject:event listener:callback thisObject:nil];
return;
}

if (offsetValue >= [[buffer data] length]) {
NSString *errorStr = [NSString stringWithFormat:@"Offset %ld is past buffer bounds (length %lu)", (long)offsetValue, (unsigned long)[[buffer data] length]];
NSMutableDictionary *event = [TiUtils dictionaryWithCode:-1 message:errorStr];
Expand Down

0 comments on commit b58349d

Please sign in to comment.