From 1c5d7f65aee365a856415adf8dbbcf4dfffa0fa6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 20 Jan 2011 18:00:07 +0000 Subject: Fix memory errors (full test suite passes with zero errors or leaks reported by valgrind). git-svn-id: http://svn.drobilla.net/serd/trunk@11 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/uri.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/uri.c b/src/uri.c index 27a53a40..5f7a405e 100644 --- a/src/uri.c +++ b/src/uri.c @@ -381,7 +381,6 @@ SerdString* serd_string_new_from_uri(const SerdURI* uri, SerdURI* out) { const size_t len = serd_uri_string_length(uri); - //SerdString* str = calloc(sizeof(SerdString) + len + 1, 1); SerdString* str = malloc(sizeof(SerdString) + len + 1); str->n_bytes = len + 1; str->n_chars = len; // FIXME: UTF-8 @@ -389,9 +388,9 @@ serd_string_new_from_uri(const SerdURI* uri, SerdURI* out) uint8_t* ptr = str->buf; const size_t actual_len = serd_uri_serialise(uri, string_sink, &ptr); - str->buf[actual_len + 1] = '\0'; + str->buf[actual_len] = '\0'; str->n_bytes = actual_len + 1; - str->n_chars = str->n_bytes - 1; + str->n_chars = str->n_bytes - 1; // FIXME: UTF-8 #ifdef URI_DEBUG fwrite("URI: `'", 1, 6, stderr); -- cgit v1.2.1