summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2009-11-24 22:34:30 -0800
committerKaz Kylheku <kaz@kylheku.com>2009-11-24 22:34:30 -0800
commit5355a54c26f6fbf6ac7a6fd74877f9ef71ab53e5 (patch)
tree25ff998dbad1a69be23fa52e1e65a1546e4d5a23
parentfbec2eb30da83f77f0f25edf0b3e3f9b6da07e07 (diff)
downloadtxr-5355a54c26f6fbf6ac7a6fd74877f9ef71ab53e5.tar.gz
txr-5355a54c26f6fbf6ac7a6fd74877f9ef71ab53e5.tar.bz2
txr-5355a54c26f6fbf6ac7a6fd74877f9ef71ab53e5.zip
Fix uninitialized memory locations.
-rw-r--r--ChangeLog12
-rw-r--r--hash.c1
-rw-r--r--lib.c4
3 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8896665a..f0a326b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2009-11-24 Kaz Kylheku <kkylheku@gmail.com>
+ Fix uninitialized memory locations.
+
+ * hash.c (make_hash): Uninitialized h->count member.
+
+ * lib.c (mkustring): Preallocated string buffer to have its
+ null terminator byte initialized, because the caller
+ does not do so (e.g. see lit_har_helper in parser.y).
+ The calling module is responsible for initializing all API-accessible
+ parts of the string, but the null belongs to the string implementation.
+
+2009-11-24 Kaz Kylheku <kkylheku@gmail.com>
+
Switching to keyword symbols for :args and :nothrow.
* lib.c (args_s, nothrow_s): Renamed to args_k and nothrow_k.
diff --git a/hash.c b/hash.c
index ae83dc7a..cc0e79f1 100644
--- a/hash.c
+++ b/hash.c
@@ -235,6 +235,7 @@ val make_hash(val weak_keys, val weak_vals)
h->flags = (hash_flags_t) flags;
h->modulus = c_num(mod);
+ h->count = 0;
h->table = table;
return hash;
diff --git a/lib.c b/lib.c
index efd77320..66622407 100644
--- a/lib.c
+++ b/lib.c
@@ -761,8 +761,10 @@ val mkstring(val len, val ch)
val mkustring(val len)
{
- wchar_t *str = (wchar_t *) chk_malloc((c_num(len) + 1) * sizeof *str);
+ cnum l = c_num(len);
+ wchar_t *str = (wchar_t *) chk_malloc((l + 1) * sizeof *str);
val s = string_own(str);
+ str[l] = 0;
s->st.len = len;
return s;
}