diff --git a/.gitignore b/.gitignore index e9230efd..ea158547 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ Makefile Makefile.in /aclocal.m4 /autom4te.cache -/build-aux /compile /configure /config.* diff --git a/.travis.yml b/.travis.yml index e1257158..47ce66db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ +os: linux language: cpp - dist: bionic addons: @@ -17,27 +17,28 @@ addons: - libunittest++-dev - hunspell-fr - libnuspell-dev + homebrew: + # Note: aspell should work on macOS, but has been removed because one of + # the tests fails; see https://github.com/Homebrew/homebrew-core/issues/4097 + packages: + - glib + - dbus-glib + - hspell + - hunspell + - libvoikko + - unittest-cpp + update: true env: global: - VERBOSE=1 # Get test logs in Travis logs -matrix: +jobs: include: - os: linux env: - - CONFIGURE_ARGS=("CFLAGS=\"-g3 -fsanitize=address -fsanitize=undefined\"" "LDFLAGS=\"-fsanitize=address -fsanitize=undefined\"") + - ASAN=yes - os: osx -before_install: - # Note: aspell should work on macOS, but has been removed from the next - # line because one of the tests fails; see - # https://github.com/Homebrew/homebrew-core/issues/40976 - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install dbus-glib hspell hunspell libvoikko unittest-cpp ; fi - script: - - ./bootstrap - - ./configure --enable-relocatable --with-zemberek=check "${CONFIGURE_ARGS[@]}" - - make - - make distcheck - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo locale-gen fr_FR.UTF-8; env LANG=fr_FR.UTF-8 make check ; fi + - ./build-aux/travis-build.sh diff --git a/NEWS b/NEWS index f3bf0726..03618e8f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +2.2.9 (July 29, 2020) +--------------------- + +Fix a couple of space leaks in the Nuspell back end (thanks, ASAN). + + 2.2.8 (February 27, 2020) ------------------------- diff --git a/build-aux/.gitignore b/build-aux/.gitignore new file mode 100644 index 00000000..9d4ab694 --- /dev/null +++ b/build-aux/.gitignore @@ -0,0 +1,15 @@ +/bootstrap.in +/compile +/config.guess +/config.sub +/depcomp +/extract-trace +/funclib.sh +/inline-source +/install-sh +/ltmain.sh +/mdate-sh +/missing +/options-parser +/test-driver +/texinfo.tex diff --git a/build-aux/travis-build.sh b/build-aux/travis-build.sh new file mode 100755 index 00000000..371326b6 --- /dev/null +++ b/build-aux/travis-build.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Build on Travis +# Written by Reuben Thomas 2020. +# This file is in the public domain. + +set -e + +./bootstrap +CONFIGURE_ARGS=(--enable-relocatable --with-zemberek=check) +if [[ "$ASAN" == "yes" ]]; then + CONFIGURE_ARGS+=(CFLAGS="-g3 -fsanitize=address -fsanitize=undefined" LDFLAGS="-fsanitize=address -fsanitize=undefined") +fi +./configure --enable-silent-rules "${CONFIGURE_ARGS[@]}" +make +make distcheck + +if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo locale-gen fr_FR.UTF-8; env LANG=fr_FR.UTF-8 make check ; fi diff --git a/configure.ac b/configure.ac index 23eb3f26..af388ca7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([enchant],[2.2.8]) +AC_INIT([enchant],[2.2.9]) AC_CONFIG_SRCDIR(src/enchant.h) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([subdir-objects]) diff --git a/providers/enchant_nuspell.cpp b/providers/enchant_nuspell.cpp index e97a3d34..1f109187 100644 --- a/providers/enchant_nuspell.cpp +++ b/providers/enchant_nuspell.cpp @@ -74,8 +74,9 @@ NuspellChecker::checkWord(const char *utf8Word, size_t len) { // the 8-bit encodings use precomposed forms char *normalizedWord = g_utf8_normalize (utf8Word, len, G_NORMALIZE_NFC); - - return nuspell.spell(string(normalizedWord)); + string s(normalizedWord); + g_free(normalizedWord); + return nuspell.spell(s); } char** @@ -83,8 +84,10 @@ NuspellChecker::suggestWord(const char* const utf8Word, size_t len, size_t *nsug { // the 8-bit encodings use precomposed forms char *normalizedWord = g_utf8_normalize (utf8Word, len, G_NORMALIZE_NFC); + string s(normalizedWord); + g_free(normalizedWord); auto suggestions = vector(); - nuspell.suggest(string(normalizedWord), suggestions); + nuspell.suggest(s, suggestions); if (suggestions.empty()) return nullptr; *nsug = suggestions.size(); @@ -254,6 +257,7 @@ NuspellChecker::requestDictionary(const char *szLang) if (!s_fileExists(aff)) return false; auto path = string(dic); + free(dic); if (path.size() >= 4 && path.compare(path.size() - 4, 4, ".dic") == 0) path.erase(path.size() - 4); else