Skip to content

Commit 9516894

Browse files
committed
Bugfix
1 parent 99a382b commit 9516894

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ColorSetKit/ColorSetStream.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,18 @@ - ( nullable NSString * )readString
150150

151151
@synchronized( self )
152152
{
153-
if( [ self read: 8 in: &n ] && n > 1 )
153+
if( [ self read: 8 in: &n ] && n > 0 )
154154
{
155-
if( ( data = [ self readDataOfLength: n - 1 ] ) )
155+
if( ( data = [ self readDataOfLength: n ] ) )
156156
{
157-
return [ [ NSString alloc ] initWithData: data encoding: NSASCIIStringEncoding ];
157+
if( data.length > 1 )
158+
{
159+
return [ [ NSString alloc ] initWithData: [ data subdataWithRange: NSMakeRange( 0, data.length - 1 ) ] encoding: NSASCIIStringEncoding ];
160+
}
161+
else
162+
{
163+
return @"";
164+
}
158165
}
159166
}
160167

0 commit comments

Comments
 (0)