Commit 1e90da42 authored by Ripinder Singh's avatar Ripinder Singh
Browse files

Fix for crash in debug mode in macos when reading windows stlye line ending



* remove_cr() utilizes strcpy with overlapped memory
* strcpy with overlapping buffers results in undefined behavior in C
* Entire buffer movement is needlessly expensinve

Signed-off-by: default avatarRipinder Singh <ripinder.singh@dolby.com>
parent 53255308
Loading
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -185,16 +185,16 @@ void convert_backslash(
void remove_cr(
    char *str )
{
    char *pos;
    int32_t n, p = 0;

    /* remove all \r characters from the string */
    pos = strchr( str, '\r' );
    while ( pos != NULL )
    for ( n = 0; str[n] != 0; n++ )
    {
        strcpy( pos, pos + 1 );
        pos = strchr( pos, '\r' );
        char c = str[n];
        str[p] = c;
        p += ( c == '\r' ) ? 0 : 1;
    }

    str[p] = 0;
    return;
}