From de507988de01c33302a708c4412e401915578153 Mon Sep 17 00:00:00 2001 From: missinglink Date: Tue, 28 Aug 2018 15:02:48 +0200 Subject: [PATCH] add patchfile for expansion memory leak --- Dockerfile | 9 ++++++++- patchfile | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 patchfile diff --git a/Dockerfile b/Dockerfile index 2985285..c38fb08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,16 @@ RUN apt-get update && \ apt-get install -y autoconf automake libtool pkg-config python && \ rm -rf /var/lib/apt/lists/* -# install libpostal +# clone libpostal RUN git clone https://github.com/openvenues/libpostal /code/libpostal WORKDIR /code/libpostal + +# patch libpostal +# https://github.com/pelias/interpolation/issues/132 +COPY patchfile /tmp/patchfile +RUN git apply /tmp/patchfile + +# install libpostal RUN ./bootstrap.sh && \ ./configure --datadir=/usr/share/libpostal && \ make && make check && make install && \ diff --git a/patchfile b/patchfile new file mode 100644 index 0000000..93fdf7b --- /dev/null +++ b/patchfile @@ -0,0 +1,15 @@ +diff --git a/src/transliterate.c b/src/transliterate.c +index 7f5fff7..83e502b 100644 +--- a/src/transliterate.c ++++ b/src/transliterate.c +@@ -938,7 +938,9 @@ char *transliterate(char *trans_name, char *str, size_t len) { + if (context_no_match && !prev_state.empty_transition && prev_state.phrase_len > 0) { + log_debug("Previous phrase stays as is %.*s\n", (int)prev_state.phrase_len, str+prev_state.phrase_start); + char_array_cat_len(new_str, str + prev_state.phrase_start, prev_state.phrase_len); +- state = start_state; ++ if (match_candidate_state.state != TRANS_STATE_PARTIAL_MATCH) { ++ state = start_state; ++ } + } + + if (state.state == TRANS_STATE_BEGIN && !prev_state.empty_transition) {