From f258ec23413c8b75680291ce3bb01fc9fed72fc5 Mon Sep 17 00:00:00 2001 From: Angelo Failla Date: Tue, 18 Apr 2017 00:10:48 -0700 Subject: [PATCH] Fix ASAN reported bug Reviewed By: yfeldblum Differential Revision: D4898404 fbshipit-source-id: 82256ae3dcd76444dc1b192d3bb6d50f142cee81 --- folly/IPAddressV6.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } -- 2.34.1