From 01c150d50546fe4c8e2cf0c3a5f1796967e47005 Mon Sep 17 00:00:00 2001 From: "Yablonskyy@axilera.com" Date: Fri, 12 Jun 2015 13:13:15 -0700 Subject: [PATCH] Add EOS checking to 'parseLeadingNumber' function. Summary: parseLeadingNumber does not contain EOS validation and raise an exception when '/sys/devices/system/cpu/cpu0/index0/shared_cpu_list' contains only one number like '0'. Closes #207 Reviewed By: @yfeldblum Differential Revision: D2148015 Pulled By: @sgolemon --- folly/detail/CacheLocality.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/folly/detail/CacheLocality.cpp b/folly/detail/CacheLocality.cpp index 8f03a9f8..26cb1265 100644 --- a/folly/detail/CacheLocality.cpp +++ b/folly/detail/CacheLocality.cpp @@ -84,7 +84,7 @@ static size_t parseLeadingNumber(const std::string& line) { auto raw = line.c_str(); char *end; unsigned long val = strtoul(raw, &end, 10); - if (end == raw || (*end != ',' && *end != '-' && *end != '\n')) { + if (end == raw || (*end != ',' && *end != '-' && *end != '\n' && *end != 0)) { throw std::runtime_error(to( "error parsing list '", line, "'").c_str()); } -- 2.34.1