From: Yablonskyy@axilera.com Date: Fri, 12 Jun 2015 20:13:15 +0000 (-0700) Subject: Add EOS checking to 'parseLeadingNumber' function. X-Git-Tag: v0.47.0~24 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=01c150d50546fe4c8e2cf0c3a5f1796967e47005;p=folly.git 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 --- 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()); }