couple of memory fixes from Mark Vakoc reported by Purify on Windows.

* threads.c uri.c: couple of memory fixes from Mark Vakoc reported
  by Purify on Windows.
Daniel
diff --git a/uri.c b/uri.c
index 10e7db6..55210a6 100644
--- a/uri.c
+++ b/uri.c
@@ -828,7 +828,7 @@
     in = str;
     out = ret;
     while(len > 0) {
-	if ((*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
+	if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
 	    in++;
 	    if ((*in >= '0') && (*in <= '9')) 
 	        *out = (*in - '0');