aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-10 22:04:24 +0100
committerDavid Robillard <d@drobilla.net>2020-11-10 22:10:15 +0100
commit48635c1e2ce5ac764cc273b4f2b93e361016d612 (patch)
tree1493b1c39b0932ede8051611d33f0c22f3df3da4
parent2ce76b31f0a9831b96830f8d60c4dee166dad37a (diff)
downloadserd-48635c1e2ce5ac764cc273b4f2b93e361016d612.tar.gz
serd-48635c1e2ce5ac764cc273b4f2b93e361016d612.tar.bz2
serd-48635c1e2ce5ac764cc273b4f2b93e361016d612.zip
Fix potential memory error when serialising URIs
-rw-r--r--NEWS3
-rw-r--r--src/uri.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index cdfc1ca2..2b37bc58 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,10 @@
serd (0.30.7) unstable;
+ * Fix potential memory error when serialising URIs
* Move headers to an include directory
* Split up and reorganize unit tests
- -- David Robillard <d@drobilla.net> Mon, 09 Nov 2020 19:02:52 +0000
+ -- David Robillard <d@drobilla.net> Tue, 10 Nov 2020 21:04:06 +0000
serd (0.30.6) stable;
diff --git a/src/uri.c b/src/uri.c
index 36e978f2..54ff1bba 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -448,7 +448,8 @@ serd_uri_serialise_relative(const SerdURI* uri,
if (uri->authority.buf) {
len += sink("//", 2, stream);
len += sink(uri->authority.buf, uri->authority.len, stream);
- if (uri->authority.buf[uri->authority.len - 1] != '/' &&
+ if (uri->authority.len > 0 &&
+ uri->authority.buf[uri->authority.len - 1] != '/' &&
serd_uri_path_starts_without_slash(uri)) {
// Special case: ensure path begins with a slash
// https://tools.ietf.org/html/rfc3986#section-3.2