diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/node.c | 2 | ||||
-rw-r--r-- | tests/serd_test.c | 3 |
3 files changed, 6 insertions, 2 deletions
@@ -1,5 +1,6 @@ serd (0.29.3) unstable; + * Fix length of base64 encoded nodes * Clarify errors returned by serd_env_expand() * Fix reported error when reading statements with only a blank node * Fix parsing local names that end with escaped dots @@ -15,7 +16,7 @@ serd (0.29.3) unstable; * Fix building with MSVC * Clean up testing code - -- David Robillard <d@drobilla.net> Sun, 27 May 2018 17:51:33 +0200 + -- David Robillard <d@drobilla.net> Sat, 14 Jul 2018 10:26:05 +0200 serd (0.28.0) stable; @@ -359,7 +359,7 @@ encode_chunk(uint8_t out[4], const uint8_t in[3], size_t n_in) SerdNode serd_node_new_blob(const void* buf, size_t size, bool wrap_lines) { - const size_t len = ((size + 2) / 3) * 4 + (wrap_lines ? (size / 57) : 0); + const size_t len = (size + 2) / 3 * 4 + (wrap_lines * ((size - 1) / 57)); uint8_t* str = (uint8_t*)calloc(1, len + 2); SerdNode node = { str, len, len, 0, SERD_LITERAL }; for (size_t i = 0, j = 0; i < size; i += 3, j += 4) { diff --git a/tests/serd_test.c b/tests/serd_test.c index e312ad04..3c2fb630 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -206,6 +206,9 @@ main(void) if (blob.n_bytes != blob.n_chars) { FAILF("Blob %zu bytes != %zu chars\n", blob.n_bytes, blob.n_chars); + } else if (blob.n_bytes != strlen((const char*)blob.buf)) { + FAILF("Blob %zu bytes != length %zu\n", + blob.n_bytes, strlen((const char*)blob.buf)); } size_t out_size; |