From 88f73a6131d89169271d886d0906cb8adaad4188 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Mon, 29 May 2023 22:48:50 +0000 Subject: [PATCH] Fix a few segfaults in http and json. --- tools/bin/td | 1 + tools/src/http.c | 5 ++++- tools/src/json.c | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/bin/td b/tools/bin/td index 7f457e1..47057f7 100644 --- a/tools/bin/td +++ b/tools/bin/td @@ -126,6 +126,7 @@ recipe_docs() { recipe_cytoplasm() { cd Cytoplasm export TLS_IMPL + export CFLAGS if ! sh make.sh; then exit 1 fi diff --git a/tools/src/http.c b/tools/src/http.c index 5ef46cd..0b32b74 100644 --- a/tools/src/http.c +++ b/tools/src/http.c @@ -199,7 +199,10 @@ Main(Array * args) HttpRequestSendHeaders(cx); StreamCopy(in, HttpClientStream(cx)); - StreamClose(in); + if (in != StreamStdin()) + { + StreamClose(in); + } } else { diff --git a/tools/src/json.c b/tools/src/json.c index 672ebcd..546334f 100644 --- a/tools/src/json.c +++ b/tools/src/json.c @@ -189,7 +189,6 @@ encode(char *str) JsonEncodeValue(val, StreamStdout(), JSON_DEFAULT); JsonValueFree(val); StreamPutc(StreamStdout(), '\n'); - JsonValueFree(val); } int