Skip to content

Commit 3e1ab70

Browse files
committed
Check return code from sam_parse1()
Fixes #1196.
1 parent b0f1eb7 commit 3e1ab70

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pysam/libcalignedsegment.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,10 @@ cdef class AlignedSegment:
10831083
_sam = force_bytes(sam)
10841084
line.s = _sam
10851085

1086-
sam_parse1(&line, dest.header.ptr, dest._delegate)
1086+
cdef int ret
1087+
ret = sam_parse1(&line, dest.header.ptr, dest._delegate)
1088+
if ret < 0:
1089+
raise ValueError("parsing SAM record string failed (error code {})".format(ret))
10871090

10881091
return dest
10891092

0 commit comments

Comments
 (0)