From c613b6955df9220dbb921e775b7aad8bcff4eee7 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Thu, 9 Feb 2017 15:56:51 +0000 Subject: [PATCH] fixed a segfault bug when the source file cannot be opened --- moo/lib/main.c | 7 +++++-- moo/libltdl/Makefile.in | 17 ++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/moo/lib/main.c b/moo/lib/main.c index f0101f1..de4019a 100644 --- a/moo/lib/main.c +++ b/moo/lib/main.c @@ -209,7 +209,6 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg) #endif if (!bb->fp) { - fclose (bb->fp); moo_seterrnum (moo, MOO_EIOERR); goto oops; } @@ -218,7 +217,11 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg) return 0; oops: - if (bb) moo_freemem (moo, bb); + if (bb) + { + if (bb->fp) fclose (bb->fp); + moo_freemem (moo, bb); + } return -1; } diff --git a/moo/libltdl/Makefile.in b/moo/libltdl/Makefile.in index 7586653..177e1b1 100644 --- a/moo/libltdl/Makefile.in +++ b/moo/libltdl/Makefile.in @@ -279,17 +279,12 @@ CTAGS = ctags CSCOPE = cscope AM_RECURSIVE_TARGETS = cscope am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config-h.in \ - $(top_srcdir)/../ac/compile \ - $(top_srcdir)/../ac/config.guess \ - $(top_srcdir)/../ac/config.sub \ - $(top_srcdir)/../ac/depcomp \ - $(top_srcdir)/../ac/install-sh \ - $(top_srcdir)/../ac/ltmain.sh \ - $(top_srcdir)/../ac/missing ../ac/compile \ - ../ac/config.guess ../ac/config.sub \ - ../ac/depcomp ../ac/install-sh \ - ../ac/ltmain.sh \ - ../ac/missing COPYING.LIB \ + $(top_srcdir)/../ac/compile $(top_srcdir)/../ac/config.guess \ + $(top_srcdir)/../ac/config.sub $(top_srcdir)/../ac/depcomp \ + $(top_srcdir)/../ac/install-sh $(top_srcdir)/../ac/ltmain.sh \ + $(top_srcdir)/../ac/missing ../ac/ar-lib ../ac/compile \ + ../ac/config.guess ../ac/config.sub ../ac/depcomp \ + ../ac/install-sh ../ac/ltmain.sh ../ac/missing COPYING.LIB \ README lt__argz.c lt__dirent.c lt__strl.c DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION)