Opened 13 years ago

Last modified 13 years ago

#1457 closed defect (fixed)

_Stold() writes to input string on certain inputs

Reported by: kwl7@… Owned by: warmerdam
Priority: highest Milestone: 1.4.1
Component: GDAL_Raster Version: 1.4.0
Severity: normal Keywords:
Cc:

Description (last modified by hobu)

Using the latest SVN (and back at least as far as 1.3.2) calling _Stold() - and indirectly through CPLStrtof() - with certain ill-formatted strings will result in letters being written to that source string.  For example, the following code:

char szTest[] = { '1', '.', '2', 'E', '+', '\0', 'H', 'i', '\0' };
std::cout << szTest << "\n";
CPLStrtof( szTest, NULL );
std::cout << szTest << "\n";

Will print:

1.2E+
1.2E+EHi

Where the null character at the end of the ill-formatted number is overwritten with an 'E'.  I believe this happens at line 463 of cpl_strtod.cpp (in SVN).  I would have included a patch, but I am not sure why that assignment is there.  Hopefully you know and have some idea of how to fix it.  ;)

Thanks,
Kevin

Change History (4)

comment:1 Changed 13 years ago by warmerdam

Andrey,

Could you look this over quickly and if applicable take over this bug?

Thanks,

comment:2 Changed 13 years ago by warmerdam

Andrey,

Any thoughts on this?  Should I have Mateusz take care of it?



comment:3 Changed 13 years ago by dron

Sorry for delay with this problem, I have overlooked it. Now it should be fixed both in HEAD and 1.4 branches.

Best regards,
Andrey

comment:4 Changed 13 years ago by hobu

Description: modified (diff)
Milestone: 1.4.1
Version: unspecified1.4.0
Note: See TracTickets for help on using tickets.