From: Angelo Failla Date: Tue, 18 Apr 2017 07:10:48 +0000 (-0700) Subject: Fix ASAN reported bug X-Git-Tag: v2017.04.24.00~11 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=f258ec23413c8b75680291ce3bb01fc9fed72fc5 Fix ASAN reported bug Reviewed By: yfeldblum Differential Revision: D4898404 fbshipit-source-id: 82256ae3dcd76444dc1b192d3bb6d50f142cee81 --- diff --git a/folly/IPAddressV6.cpp b/folly/IPAddressV6.cpp index c7a93efe..57d00aa4 100644 --- a/folly/IPAddressV6.cpp +++ b/folly/IPAddressV6.cpp @@ -186,14 +186,14 @@ IPAddressV6 IPAddressV6::fromInverseArpaName(const std::string& arpaname) { throw IPAddressFormatException(sformat("Invalid input. Got '{}'", piece)); } std::array ip; - int pos = 0; + size_t pos = 0; int count = 0; for (int p = pieces.size() - 1; p >= 0; p--) { ip[pos] = pieces[p][0]; pos++; count++; // add ':' every 4 chars - if (count == 4) { + if (count == 4 && pos < ip.size()) { ip[pos++] = ':'; count = 0; }