edgar-mtz-e / slimdx

Automatically exported from code.google.com/p/slimdx
0 stars 0 forks source link

Off-by-one error in Color4Converter.cpp #402

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the following code snippet, 'stringArray' is being incorrectly indexed 
with indices 1, 2, and 3.  The correct indices are 0, 1, and 2.

            else if( stringArray->Length == 3 )
            {
                int red;
                int green;
                int blue;
                if( int::TryParse( stringArray[0], red ) && 
int::TryParse( stringArray[1], green ) && int::TryParse( stringArray[2], 
blue ) )
                    return gcnew Color4( 
Color::FromArgb( red, green, blue ) );

                float r = safe_cast<float>( floatConverter-
>ConvertFromString( context, culture, stringArray[1] ) );
                float g = safe_cast<float>( floatConverter-
>ConvertFromString( context, culture, stringArray[2] ) );
                float b = safe_cast<float>( floatConverter-
>ConvertFromString( context, culture, stringArray[3] ) );

                return gcnew Color4( r, g, b );
            }

Original issue reported on code.google.com by shawnpre...@gmail.com on 13 Jan 2009 at 6:09

GoogleCodeExporter commented 9 years ago
Accepted.

Original comment by Mike.Popoloski on 13 Jan 2009 at 7:08

GoogleCodeExporter commented 9 years ago
Fixed as of r861.

Original comment by Mike.Popoloski on 14 Jan 2009 at 7:57