mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add safe guard when receive network response data too long (#41717)
Summary: Fixes https://github.com/facebook/react-native/issues/41651 ## Changelog: [IOS] [FIXED] - Add safe guard when receive network response data too long Pull Request resolved: https://github.com/facebook/react-native/pull/41717 Test Plan: None. Reviewed By: cortinico Differential Revision: D51981597 Pulled By: dmytrorykun fbshipit-source-id: fabaa1490684da6725270e8ca617e3da97c56978
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d5b1c71b3f
commit
3c4517ffb6
@@ -164,7 +164,21 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
if (!_data) {
|
||||
_data = [NSMutableData new];
|
||||
}
|
||||
[_data appendData:data];
|
||||
@try {
|
||||
[_data appendData:data];
|
||||
} @catch (NSException *exception) {
|
||||
_status = RCTNetworkTaskFinished;
|
||||
if (_completionBlock) {
|
||||
RCTURLRequestCompletionBlock completionBlock = _completionBlock;
|
||||
[self dispatchCallback:^{
|
||||
completionBlock(
|
||||
self->_response, nil, RCTErrorWithMessage(exception.reason ?: @"Request's received data too long."));
|
||||
}];
|
||||
}
|
||||
[self invalidate];
|
||||
return;
|
||||
}
|
||||
|
||||
length = _data.length;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user