diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2011-10-05 23:06:26 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2011-10-05 23:06:26 +0200 |
commit | ec6e04244ea7658817b4c21e39939f16490bf89c (patch) | |
tree | 6e6f781bc170acb29773ac56f7aad187f038d41e /ftparchive/cachedb.cc | |
parent | d073d7db69eddd2d9c22e8ded7c6b871bca1716a (diff) | |
parent | 324fc8af296953857ebfc76deaadd4d224e081e3 (diff) |
merge with current debian apt/sid
Diffstat (limited to 'ftparchive/cachedb.cc')
-rw-r--r-- | ftparchive/cachedb.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc index b04244347..6573fa264 100644 --- a/ftparchive/cachedb.cc +++ b/ftparchive/cachedb.cc @@ -294,11 +294,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) { |