fixed a segfault bug when the source file cannot be opened

This commit is contained in:
hyunghwan.chung 2017-02-09 15:56:51 +00:00
parent 2a40be7742
commit c613b6955d
2 changed files with 11 additions and 13 deletions

View File

@ -209,7 +209,6 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
#endif #endif
if (!bb->fp) if (!bb->fp)
{ {
fclose (bb->fp);
moo_seterrnum (moo, MOO_EIOERR); moo_seterrnum (moo, MOO_EIOERR);
goto oops; goto oops;
} }
@ -218,7 +217,11 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
return 0; return 0;
oops: oops:
if (bb) moo_freemem (moo, bb); if (bb)
{
if (bb->fp) fclose (bb->fp);
moo_freemem (moo, bb);
}
return -1; return -1;
} }

View File

@ -279,17 +279,12 @@ CTAGS = ctags
CSCOPE = cscope CSCOPE = cscope
AM_RECURSIVE_TARGETS = cscope AM_RECURSIVE_TARGETS = cscope
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config-h.in \ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config-h.in \
$(top_srcdir)/../ac/compile \ $(top_srcdir)/../ac/compile $(top_srcdir)/../ac/config.guess \
$(top_srcdir)/../ac/config.guess \ $(top_srcdir)/../ac/config.sub $(top_srcdir)/../ac/depcomp \
$(top_srcdir)/../ac/config.sub \ $(top_srcdir)/../ac/install-sh $(top_srcdir)/../ac/ltmain.sh \
$(top_srcdir)/../ac/depcomp \ $(top_srcdir)/../ac/missing ../ac/ar-lib ../ac/compile \
$(top_srcdir)/../ac/install-sh \ ../ac/config.guess ../ac/config.sub ../ac/depcomp \
$(top_srcdir)/../ac/ltmain.sh \ ../ac/install-sh ../ac/ltmain.sh ../ac/missing COPYING.LIB \
$(top_srcdir)/../ac/missing ../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 README lt__argz.c lt__dirent.c lt__strl.c
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE)-$(VERSION)