From cab5c25c70b884fe5428c4bfbd043316ff642518 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 6 Mar 2014 22:04:07 -0300 Subject: [PATCH] Fix memory leak and enable valgrind on travis --- .travis.yml | 1 - scripts/travis.sh | 4 ++-- src/os/fs.c | 9 +++++++-- src/testdir/Makefile | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index c154eb68b3..2346f865e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: c script: ./scripts/travis.sh before_install: - - sudo apt-get update - sudo apt-get install valgrind compiler: - clang diff --git a/scripts/travis.sh b/scripts/travis.sh index 05747a18aa..c493da29b5 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -1,11 +1,11 @@ #!/bin/sh -e -# export VALGRIND_CHECK=1 +export VALGRIND_CHECK=1 make cmake CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$PWD/dist" make make unittest echo "Running tests with valgrind..." -if ! make test > /dev/null; then +if ! make test; then if ls src/testdir/valgrind.* > /dev/null 2>&1; then echo "Memory leak detected" >&2 cat src/testdir/valgrind.* diff --git a/src/os/fs.c b/src/os/fs.c index b55c132027..6ae48ab269 100644 --- a/src/os/fs.c +++ b/src/os/fs.c @@ -175,11 +175,16 @@ int mch_is_absolute_path(char_u *fname) int mch_isdir(char_u *name) { uv_fs_t request; - if (0 != uv_fs_stat(uv_default_loop(), &request, (const char*) name, NULL)) { + int result = uv_fs_stat(uv_default_loop(), &request, (const char*) name, NULL); + uint64_t mode = request.statbuf.st_mode; + + uv_fs_req_cleanup(&request); + + if (0 != result) { return FALSE; } - if (!S_ISDIR(request.statbuf.st_mode)) { + if (!S_ISDIR(mode)) { return FALSE; } diff --git a/src/testdir/Makefile b/src/testdir/Makefile index f096cb5b70..be4fc279ab 100644 --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -28,7 +28,7 @@ SCRIPTS := test1.out test2.out test3.out test4.out test5.out test6.out \ SCRIPTS_GUI := test16.out ifdef VALGRIND_CHECK -VALGRIND = valgrind --suppressions=../../.valgrind.supp --leak-check=full --error-exitcode=111 --log-file=valgrind.$* +VALGRIND = valgrind --suppressions=../../.valgrind.supp --leak-check=full --error-exitcode=123 --log-file=valgrind.$* endif ifdef TESTNUM