summaryrefslogtreecommitdiffstats
path: root/buf.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-05-04 06:47:24 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-05-04 06:47:24 -0700
commit0c07bd4a499379c47916ce7cbf8d03af79e3aa98 (patch)
tree93f223db2e75262e024e2f84012241a67ec5211b /buf.h
parent9a7f2d51807c182c7cb7e554c3be109ccd066ad8 (diff)
downloadtxr-0c07bd4a499379c47916ce7cbf8d03af79e3aa98.tar.gz
txr-0c07bd4a499379c47916ce7cbf8d03af79e3aa98.tar.bz2
txr-0c07bd4a499379c47916ce7cbf8d03af79e3aa98.zip
sha256/md5: leak: don't use borrowed buffer for hash.
It's incorrect to use a borrowed buf, because a borrowed buf assumes that the memory isn't dynamically allocated, and will not free it when it is finalized by the garbage collector. The buffer which holds the hash returned by sha256 and md5 does in fact own the memory. * buf.c (make_owned_buf): Static function becomes external. * buf.h (make_owned_buf): Declared. * chksum.c (chksum_ensure_buf): Use make_owned_buf rather than make_borrowed_buf.
Diffstat (limited to 'buf.h')
-rw-r--r--buf.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/buf.h b/buf.h
index 683d5438..1805f3b8 100644
--- a/buf.h
+++ b/buf.h
@@ -29,6 +29,7 @@ val make_buf(val len, val init_val, val alloc_size);
val bufp(val object);
val make_borrowed_buf(val len, mem_t *data);
val init_borrowed_buf(obj_t *buf, val len, mem_t *data);
+val make_owned_buf(val len, mem_t *data);
val make_duplicate_buf(val len, mem_t *data);
val copy_buf(val buf);
val buf_trim(val buf);