From 052f6ee3e6351859859864e8d1b6bf5824435c9f Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Tue, 5 Apr 2022 12:29:56 +0000 Subject: [PATCH] Change arr_ind order FossilOrigin-Name: f992a1d3deed9975079c1955a5e22a208be59279588ae25194f825e72ede9f4e --- include/mastodont_request.h | 1 + src/query.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/mastodont_request.h b/include/mastodont_request.h index 0e1f94e..7cb3ebc 100644 --- a/include/mastodont_request.h +++ b/include/mastodont_request.h @@ -18,6 +18,7 @@ #include "mastodont.h" #include "mastodont_types.h" #include "mastodont_fetch.h" +#include "mastodont_query.h" struct mastodont_request_args { diff --git a/src/query.c b/src/query.c index 985bbf0..8761530 100644 --- a/src/query.c +++ b/src/query.c @@ -49,7 +49,7 @@ char* _mstdnt_query_string(mastodont_t* data, res_len = 0; char* result = malloc(res_len); if (src_l) - strncpy(result, src, res_len); + strcpy(result, src); /* We'll call them res to represent the query parameters */ int res_count = 0; @@ -71,7 +71,9 @@ char* _mstdnt_query_string(mastodont_t* data, } if (params[i].type != _MSTDNT_QUERY_ARRAY) + { key_ptr = params[i].key; + } if (key_ptr && !(params[i].type == _MSTDNT_QUERY_STRING && @@ -127,18 +129,20 @@ char* _mstdnt_query_string(mastodont_t* data, curl_free(escape_str); } - ++arr_ind; /* Finish array stuff */ if (params[i].type == _MSTDNT_QUERY_ARRAY) + { + ++arr_ind; + if (arr_ind >= params[i].value.a.arr_len) { arr_ind = 0; free(key_ptr); } else { - ++arr_ind; --i; /* Flip flop i */ } + } } return result;