Skip to content

Commit 4c43706

Browse files
authored
Merge pull request #4 from dpryan79/fixSegFault
Fix seg fault
2 parents f526186 + d475720 commit 4c43706

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

2bit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void bytes2bases(char *seq, uint8_t *byte, uint32_t sz, int offset) {
7272
while(offset < 4) {
7373
seq[pos++] = byte2base(foo, offset++);
7474
}
75+
if(pos >= sz) return;
7576
foo = byte[++i];
7677
}
7778

@@ -158,9 +159,10 @@ void softMask(char *seq, TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end)
158159
*/
159160
char *constructSequence(TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end) {
160161
uint32_t sz = end - start + 1;
161-
uint32_t blockStart, blockEnd, offset;
162+
uint32_t blockStart, blockEnd;
162163
char *seq = malloc(sz * sizeof(char));
163164
uint8_t *bytes = NULL;
165+
int offset;
164166
if(!seq) return NULL;
165167

166168
//There are 4 bases/byte

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
0.2.1:
2+
- Fixed a segfault that occurs if a 1 or 2 base sequence is requested that does not overlap either the start or end of a byte.
3+
14
0.2.0:
25
- The `twobitBasesWorker()` and `constructSequence()` functions that underly `twobitSequence()` and `twobitBases()` have been rewritten and are now much faster.
36

0 commit comments

Comments
 (0)