diff options
author | Nikias Bassen | 2021-11-08 03:12:51 +0100 |
---|---|---|
committer | Nikias Bassen | 2021-11-08 03:12:51 +0100 |
commit | a9e34bd29ae9dcdae55bdf5fb8a23c9b1c02eee9 (patch) | |
tree | abe78c18c6f5538980631bb60f7f0f1eb471bcb2 /src | |
parent | cf7a3f3d7c06b197ee71c9f97eb9aa05f26d63b5 (diff) | |
download | libplist-a9e34bd29ae9dcdae55bdf5fb8a23c9b1c02eee9.tar.gz libplist-a9e34bd29ae9dcdae55bdf5fb8a23c9b1c02eee9.tar.bz2 |
xplist: Better size estimation for PLIST_REAL nodes
Diffstat (limited to 'src')
-rw-r--r-- | src/xplist.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/xplist.c b/src/xplist.c index 263d88e..2eaba55 100644 --- a/src/xplist.c +++ b/src/xplist.c @@ -113,7 +113,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval) } else { size_t i = 0; len = snprintf(buf, bufsize, "%.*g", 17, realval); - for (i = 0; i < len; i++) { + for (i = 0; buf && i < len; i++) { if (buf[i] == ',') { buf[i] = '.'; break; @@ -479,7 +479,7 @@ static void node_estimate_size(node_t *node, uint64_t *size, uint32_t depth) *size += (XPLIST_INT_LEN << 1) + 6; break; case PLIST_REAL: - *size += num_digits_i((int64_t)data->realval) + 7; + *size += dtostr(NULL, 0, data->realval); *size += (XPLIST_REAL_LEN << 1) + 6; break; case PLIST_DATE: |