libidav/utils.c

changeset 124
41939c8f3f9c
parent 119
451607eeff05
child 147
458a8dc68048
--- a/libidav/utils.c	Fri May 29 14:16:45 2015 +0200
+++ b/libidav/utils.c	Sat May 30 13:49:17 2015 +0200
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 #include <ucx/string.h>
 #include <ucx/buffer.h>
 #include <ucx/utils.h>
@@ -75,8 +76,9 @@
 
 int util_strtoint(char *str, int64_t *value) {
     char *end;
+    errno = 0;
     int64_t val = strtoll(str, &end, 0);
-    if(strlen(end) == 0) {
+    if(errno == 0) {
         *value = val;
         return 1;
     } else {

mercurial