diff --git a/http/http_request.c b/http/http_request.c
index ec9b77d..40b1cd7 100644
--- a/http/http_request.c
+++ b/http/http_request.c
@@ -125,8 +125,10 @@ sw http_request_buf_write (s_http_request *req, s_buf *buf)
}
if (! str_init_to_upper(&str, &req->method->str))
return -1;
- if ((r = buf_write_str(buf, &str)) < 0)
+ if ((r = buf_write_str(buf, &str)) < 0) {
+ str_clean(&str);
return r;
+ }
result += r;
str_clean(&str);
if ((r = buf_write_1(buf, " ")) <= 0)
diff --git a/lib/kc3/0.1/list.kc3 b/lib/kc3/0.1/list.kc3
index 962245b..6748287 100644
--- a/lib/kc3/0.1/list.kc3
+++ b/lib/kc3/0.1/list.kc3
@@ -2,7 +2,7 @@ defmodule List do
def cast = cfn List "list_init_cast" (Result, Sym, Tag)
- def has? = cfn Bool "list_has" (List, Tag)
+ def has? = cfn Bool "list_has" (List, Tag, Result)
def map = fn {
([], _) do
diff --git a/libkc3/list.c b/libkc3/list.c
index d2840e8..75a10a3 100644
--- a/libkc3/list.c
+++ b/libkc3/list.c
@@ -58,16 +58,20 @@ void list_f_clean (s_list **list)
l = list_delete(l);
}
-bool list_has (const s_list * const *list, const s_tag *tag)
+bool * list_has (const s_list * const *list, const s_tag *tag,
+ bool *dest)
{
const s_list *l;
l = *list;
while (l) {
- if (! compare_tag(tag, &l->tag))
- return true;
+ if (! compare_tag(tag, &l->tag)) {
+ *dest = true;
+ return dest;
+ }
l = list_next(l);
}
- return false;
+ *dest = false;
+ return dest;
}
s_list * list_init (s_list *list, s_list *next)
diff --git a/libkc3/list.h b/libkc3/list.h
index cd66e87..0100283 100644
--- a/libkc3/list.h
+++ b/libkc3/list.h
@@ -50,7 +50,8 @@ s_list * list_new_tag_copy (const s_tag *tag, s_list *next);
/* Observers */
s_list ** list_cast (const s_tag *tag, s_list **list);
-bool list_has (const s_list * const *list, const s_tag *tag);
+bool * list_has (const s_list * const *list, const s_tag *tag,
+ bool *dest);
bool list_is_alist (const s_list * const *list);
bool list_is_plist (const s_list *list);
sw list_length (const s_list *list);
diff --git a/test/ikc3/list.kc3 b/test/ikc3/list.kc3
index 7433dc6..2a4dea4 100644
--- a/test/ikc3/list.kc3
+++ b/test/ikc3/list.kc3
@@ -46,3 +46,9 @@ List.map([1, 2, 3, 4], fn (x) { x * 2 })
quote List.reverse([1, 2, 3, 4])
List.reverse([1, 2, 3, 4])
+
+quote List.has?([:read], :read)
+List.has?([:read], :read)
+
+quote List.has?([:read], :write)
+List.has?([:read], :write)
diff --git a/test/ikc3/list.out.expected b/test/ikc3/list.out.expected
index 7837778..a04e6c9 100644
--- a/test/ikc3/list.out.expected
+++ b/test/ikc3/list.out.expected
@@ -24,3 +24,7 @@ List.map([1, 2, 3, 4], fn (x) { x * 2 })
[2, 4, 6, 8]
List.reverse([1, 2, 3, 4])
[4, 3, 2, 1]
+List.has?([:read], :read)
+true
+List.has?([:read], :write)
+false