title: I'm getting a segfault and can't seem to find it
body: <p>The code below is segfaulting randomly and I can't seem to see what the problem it. Any help would be appreciated. I isolated it to this function using gdb and core files.</p>
  
  <pre><code>char* chomp(char *str)
  {
     unsigned int scan_ind, curr_ind;
  
     scan_ind = curr_ind = 0;
  
     while(str[scan_ind])
     {
        if(str[scan_ind] != 0x0A &amp;&amp;
           str[scan_ind] != 0x0D)
        {
           if(curr_ind != scan_ind)
              str[curr_ind] = str[scan_ind];
  
           curr_ind++;
        }
  
        scan_ind++;
     }
  
     str[curr_ind] = 0;
  
     return str;
  }
  </code></pre>