Skip to content

Commit 9fee7f4

Browse files
committed
stdlib: Fix fcvtbuf/ecvtbuf to handle inf/nan values
__dtoa returns a magic value in decpt (9999) for inf/nan values which the fcvtbuf/ecvtbuf wrappers need to check for (as other __dtoa users already do). Signed-off-by: Keith Packard <[email protected]>
1 parent 66213f8 commit 9fee7f4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

newlib/libc/stdlib/ecvtbuf.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ fcvtbuf (double invalue,
276276
if (!p)
277277
return NULL;
278278

279+
if (*decpt == 9999)
280+
{
281+
strcpy(fcvt_buf, p);
282+
return fcvt_buf;
283+
}
284+
279285
/* Now copy */
280286

281287
done = -*decpt;
@@ -327,6 +333,12 @@ ecvtbuf (double invalue,
327333
if (!p)
328334
return NULL;
329335

336+
if (*decpt == 9999)
337+
{
338+
strcpy(fcvt_buf, p);
339+
return fcvt_buf;
340+
}
341+
330342
/* Now copy */
331343

332344
while (p < end)

0 commit comments

Comments
 (0)