Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for very long input lines (> 2Gbyte) #1542

Merged
merged 3 commits into from Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bgzf.c
Expand Up @@ -2298,7 +2298,7 @@ int bgzf_getline(BGZF *fp, int delim, kstring_t *str)
fp->uncompressed_address += str->l + 1;
if ( delim=='\n' && str->l>0 && str->s[str->l-1]=='\r' ) str->l--;
str->s[str->l] = 0;
return str->l;
return str->l <= INT_MAX ? (int) str->l : INT_MAX;
}

void bgzf_index_destroy(BGZF *fp)
Expand Down
3 changes: 2 additions & 1 deletion htslib/bgzf.h
Expand Up @@ -303,7 +303,8 @@ typedef struct BGZF BGZF;
* @param fp BGZF file handler
* @param delim delimiter
* @param str string to write to; must be initialized
* @return length of the string; -1 on end-of-file; <= -2 on error
* @return length of the string (capped at INT_MAX);
* -1 on end-of-file; <= -2 on error
*/
HTSLIB_EXPORT
int bgzf_getline(BGZF *fp, int delim, struct kstring_t *str);
Expand Down
5 changes: 3 additions & 2 deletions tbx.c
Expand Up @@ -91,9 +91,10 @@ int tbx_name2id(tbx_t *tbx, const char *ss)
return get_tid(tbx, ss, 0);
}

int tbx_parse1(const tbx_conf_t *conf, int len, char *line, tbx_intv_t *intv)
int tbx_parse1(const tbx_conf_t *conf, size_t len, char *line, tbx_intv_t *intv)
{
int i, b = 0, id = 1;
size_t i, b = 0;
int id = 1;
char *s;
intv->ss = intv->se = 0; intv->beg = intv->end = -1;
for (i = 0; i <= len; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion vcf.c
Expand Up @@ -3437,7 +3437,7 @@ int vcf_write_line(htsFile *fp, kstring_t *line)

int vcf_write(htsFile *fp, const bcf_hdr_t *h, bcf1_t *v)
{
int ret;
ssize_t ret;
fp->line.l = 0;
if (vcf_format1(h, v, &fp->line) != 0)
return -1;
Expand Down