From c2612d08e13465ce3a634be631bb2bdd380f1e04 Mon Sep 17 00:00:00 2001 From: Michael Kolupaev Date: Mon, 18 Mar 2013 10:39:47 +0000 Subject: [PATCH] clickhouse: fixed function cutURLParameter [#CONV-6788]. --- dbms/include/DB/Functions/FunctionsURL.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dbms/include/DB/Functions/FunctionsURL.h b/dbms/include/DB/Functions/FunctionsURL.h index 43c077bf3d8..70e255c044f 100644 --- a/dbms/include/DB/Functions/FunctionsURL.h +++ b/dbms/include/DB/Functions/FunctionsURL.h @@ -386,14 +386,15 @@ struct CutURLParameterImpl /// Захватим ';' или '&' до или после параметра. if (*end_pos == ';' || *end_pos == '&') ++end_pos; - else if (*(begin_pos-1) == ';' || *(begin_pos) == '&') + else if (*(begin_pos - 1) == ';' || *(begin_pos - 1) == '&') --begin_pos; } while (false); - res_data.resize(res_offset + (url_end - url_begin) + 1); + size_t cut_length = (url_end - url_begin) - (end_pos - begin_pos); + res_data.resize(res_offset + cut_length + 1); memcpy(&res_data[res_offset], url_begin, begin_pos - url_begin); memcpy(&res_data[res_offset] + (begin_pos - url_begin), end_pos, url_end - end_pos); - res_offset += url_end - url_begin + 1; + res_offset += cut_length + 1; res_data[res_offset - 1] = 0; res_offsets[i] = res_offset;