From eed5fc7179b2f2686321630edf3914aaa9d8e574 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sat, 14 Jun 2008 21:02:52 +0000 Subject: [PATCH] * libmisc/getlong.c: Reset errno before calling strtol(). Otherwise, errno could be already set to ERANGE. --- ChangeLog | 5 +++++ libmisc/getlong.c | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1f12e660..fcde3dfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-06-14 Nicolas François + + * libmisc/getlong.c: Reset errno before calling strtol(). + Otherwise, errno could be already set to ERANGE. + 2008-06-14 Nicolas François * libmisc/Makefile.am, libmisc/getrange.c: Added function to parse diff --git a/libmisc/getlong.c b/libmisc/getlong.c index 7ea3a80d..7c3d2ce0 100644 --- a/libmisc/getlong.c +++ b/libmisc/getlong.c @@ -39,6 +39,7 @@ int getlong(const char *numstr, long int *result) long val; char *endptr; + errno = 0; val = strtol (numstr, &endptr, 10); if (('\0' != *endptr) || (ERANGE == errno)) { return 0;