#44 exp_file.c segmentation fault

closed-fixed
Gap4 (50)
5
2005-09-27
2005-08-04
Anonymous
No

This piece of code is resulting in a sementation fault
because I have some values in my exp file that are bad
(from vector_clip?) Seem's like there could be some
better validation of the values:

if (exp_Nentries(si->e, EFLT_CL) &&
exp_Nentries(si->e, EFLT_CR)) {
int l = atoi(exp_get_entry(si->e, EFLT_CL));
int r = atoi(exp_get_entry(si->e, EFLT_CR));
for (; r >= l; r--) {
if (seq[r] != '*')
seq[r] = 'X';
}
}

I changed the above to the below code to get around the
segmentation fault and print out some informative
information:

if (exp_Nentries(si->e, EFLT_CL) &&
exp_Nentries(si->e, EFLT_CR)) {
int l = atoi(exp_get_entry(si->e, EFLT_CL));
int r = atoi(exp_get_entry(si->e, EFLT_CR));
if ((r >= 0 && r < seq_length) && (l >= 0 && l <
0)) {
for (; r >= l; r--) {
if (seq[r] != '*')
seq[r] = 'X';
}
} else {
printf("WARNING cannot X out vector
sequence!!\nCL (%d) and CR (%d) values not within
sequence range 1 - %d\n", l, r, seq_length);
}
}

cristyn@@broad.mit.edu "Cristyn Kells"

Discussion

  • James Bonfield

    James Bonfield - 2005-09-27

    Logged In: YES
    user_id=154581

    I'm unsure of why you have "&& (l >= 0 && l < 0)" as that
    evaluates to false regardless of what value l is.

    I changed the check to specifically deal with seq[r] being
    out of range. Ie:

    for (; r >= l; r--) {
    if (r >= 0 && r < seq_len && seq[r] != '*')
    seq[r] = 'X';
    }

    I'll upload this with other changes soon.

    James

     
  • James Bonfield

    James Bonfield - 2005-09-27
    • assigned_to: nobody --> jkbonfield
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks