X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/afd7b358f94efddb83a2911ec1a21e7280074b1e..7be8c02360bdb9bd7f59b087da874f88af2a7206:/ftparchive/cachedb.cc diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc index a1d70f912..6eccb8d4a 100644 --- a/ftparchive/cachedb.cc +++ b/ftparchive/cachedb.cc @@ -299,11 +299,15 @@ bool CacheDB::LoadContents(bool const &GenOnly) /*}}}*/ static string bytes2hex(uint8_t *bytes, size_t length) { - char space[65]; - if (length * 2 > sizeof(space) - 1) length = (sizeof(space) - 1) / 2; - for (size_t i = 0; i < length; i++) - snprintf(&space[i*2], 3, "%02x", bytes[i]); - return string(space); + char buf[3]; + string space; + + space.reserve(length*2 + 1); + for (size_t i = 0; i < length; i++) { + snprintf(buf, sizeof(buf), "%02x", bytes[i]); + space.append(buf); + } + return space; } static inline unsigned char xdig2num(char const &dig) {