| Summary: | Obvious bugs in SDL_ltoa and SDL_lltoa | ||
|---|---|---|---|
| Product: | SDL | Reporter: | pjz <acme_pjz> |
| Component: | *don't know* | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | r.kreis |
| Version: | 2.0.0 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
fix SDL_ltoa and SDL_lltoa for minimum values
do fix SDL_ltoa and SDL_lltoa for minimum values |
||
Created attachment 1486 [details]
fix SDL_ltoa and SDL_lltoa for minimum values
Simply making SDL_ltoa/SDL_lltoa use SDL_ultoa/SDL_ulltoa with the absolute (and thus unsigned) value fixes this.
Created attachment 1487 [details]
do fix SDL_ltoa and SDL_lltoa for minimum values
This one actually uses SDL_ulltoa inside SDL_lltoa, as promised.
Good catch, thanks! https://hg.libsdl.org/SDL/rev/8e4512b74223 |
SDL_ltoa(-2147483648,s,10) only returns "-" because there is a bug in the code: if ( value < 0 ) { *bufp++ = '-'; value = -value; } but -(-2147483648) is still -2147483648 (0x80000000) as signed int (or long), so the following loop doesn't run at all. Similar bug are also in SDL_lltoa. BTW, there is no sanity check for radix.