From 3ef840452239bcb3c69cdef177b535bb013c75f3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 May 2022 23:00:52 -0400 Subject: [PATCH] vere: refactors getting next version string --- pkg/urbit/vere/king.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/urbit/vere/king.c b/pkg/urbit/vere/king.c index 6c6010e83..4d4563211 100644 --- a/pkg/urbit/vere/king.c +++ b/pkg/urbit/vere/king.c @@ -349,11 +349,7 @@ _king_get_next(c3_c* pac_c, c3_c** out_c) ret_i = asprintf(&url_c, "%s/%s/%s/next", ver_hos_c, pac_c, URBIT_VERSION); c3_assert( ret_i > 0 ); - if ( !_king_curl_bytes(url_c, &len_w, &hun_y) ) { - ret_i = asprintf(&ver_c, "%.*s", len_w, hun_y); - c3_assert( ret_i > 0 ); - } - else { + if ( _king_curl_bytes(url_c, &len_w, &hun_y) ) { c3_free(url_c); // XX support channel redirections @@ -366,14 +362,17 @@ _king_get_next(c3_c* pac_c, c3_c** out_c) c3_free(url_c); return -2; } - - ret_i = asprintf(&ver_c, "%.*s", len_w, hun_y); - c3_assert( ret_i > 0 ); } - c3_free(hun_y); c3_free(url_c); + // null-terminate + // + hun_y = c3_realloc(hun_y, 1 + len_w); + hun_y[len_w] = 0; + + ver_c = (c3_c*)hun_y; + // XX trim ver_c ? // if ( 0 == strcmp(ver_c, URBIT_VERSION) ) {