diff --git a/ext/bio/twobit/2bit.c b/ext/bio/twobit/2bit.c index df56782..bb0eee9 100644 --- a/ext/bio/twobit/2bit.c +++ b/ext/bio/twobit/2bit.c @@ -69,7 +69,7 @@ void bytes2bases(char *seq, uint8_t *byte, uint32_t sz, int offset) { // Deal with the first partial byte if(offset != 0) { - while(offset < 4) { + while(offset < 4 && pos < sz) { seq[pos++] = byte2base(foo, offset++); } if(pos >= sz) return;