Permalink
Browse files

bugfix: segfault in ksw

  • Loading branch information...
1 parent b45806f commit 91dad44653196396faea33287296be464ccbaa2a @lh3 lh3 committed Apr 5, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 ksw.c
View
4 ksw.c
@@ -329,18 +329,20 @@ static void revseq(int l, uint8_t *s)
kswr_t ksw_align(int qlen, uint8_t *query, int tlen, uint8_t *target, int m, const int8_t *mat, int gapo, int gape, int xtra, kswq_t **qry)
{
+ int size;
kswq_t *q;
kswr_t r, rr;
kswr_t (*func)(kswq_t*, int, const uint8_t*, int, int, int);
q = (qry && *qry)? *qry : ksw_qinit((xtra&KSW_XBYTE)? 1 : 2, qlen, query, m, mat);
if (qry && *qry == 0) *qry = q;
func = q->size == 2? ksw_i16 : ksw_u8;
+ size = q->size;
r = func(q, tlen, target, gapo, gape, xtra);
if (qry == 0) free(q);
if ((xtra&KSW_XSTART) == 0 || ((xtra&KSW_XSUBO) && r.score < (xtra&0xffff))) return r;
revseq(r.qe + 1, query); revseq(r.te + 1, target); // +1 because qe/te points to the exact end, not the position after the end
- q = ksw_qinit((*qry)->size, r.qe + 1, query, m, mat);
+ q = ksw_qinit(size, r.qe + 1, query, m, mat);
rr = func(q, tlen, target, gapo, gape, KSW_XSTOP | r.score);
revseq(r.qe + 1, query); revseq(r.te + 1, target);
free(q);

0 comments on commit 91dad44

Please sign in to comment.