Browse code

bb11441 - fixing edge case revealed by unit testing

Mickey Sola authored on 2016/01/14 03:18:01
Showing 1 changed files
... ...
@@ -584,8 +584,10 @@ static void screnc_decode(unsigned char *ptr, struct screnc_state *s)
584 584
 		} else {
585 585
 			*dst++ = *ptr++;
586 586
 			*dst++ = *ptr;
587
-			if (!*ptr)
587
+			if (!*ptr) {
588
+				dst--;
588 589
 				break;
590
+			}
589 591
 		}
590 592
 		ptr++;
591 593
 		s->length--;
... ...
@@ -618,7 +620,7 @@ static void screnc_decode(unsigned char *ptr, struct screnc_state *s)
618 618
 		remaining = strlen((const char*)ptr) + 1;
619 619
 		memmove(dst, ptr, remaining);
620 620
 	} else {
621
-		*ptr = '\0';
621
+		*dst = '\0';
622 622
 	}
623 623
 }
624 624