You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a segment of code that's incorrect here that can cause crashes:
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode
{
switch(eventCode)
{
case NSStreamEventHasBytesAvailable:
{
uint8_t buf[1024];
memset(buf, 0, sizeof(uint8_t) * 1024);
unsigned int len = 0;
len = [(NSInputStream *)stream read:buf maxLength:1024];
if(len) {
The documentation for read:maxLength: says it can return a negative number on
failure. So len should be signed, and the if statement modified:
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode
{
switch(eventCode)
{
case NSStreamEventHasBytesAvailable:
{
uint8_t buf[1024];
memset(buf, 0, sizeof(uint8_t) * 1024);
NSInteger len = 0;
len = [(NSInputStream *)stream read:buf maxLength:1024];
if(len > 0)
Original issue reported on code.google.com by [email protected] on 30 Jun 2011 at 2:16
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
[email protected]
on 30 Jun 2011 at 2:16The text was updated successfully, but these errors were encountered: