fixed error handling in qse_dir_init()

This commit is contained in:
hyung-hwan 2012-11-16 17:11:18 +00:00
parent 034d3e9c04
commit 105c862230
3 changed files with 13 additions and 3 deletions

View File

@ -1477,7 +1477,7 @@ void* StdAwk::modsym (void* handle, const qse_char_t* name)
qse_mchar_t* mname;
#if defined(QSE_CHAR_IS_MCHAR)
mname = name;
mname = (qse_mchar_t*)name;
#else
mname = qse_wcstombsdup (name, QSE_NULL, this->getMmgr());
if (!mname)

View File

@ -1331,7 +1331,7 @@ qse_wchar_t* qse_awk_rtx_valtowcsdup (
out.type = QSE_AWK_RTX_VALTOSTR_CPLDUP;
if (qse_awk_rtx_valtostr (rtx, v, &out) <= -1) return QSE_NULL;
wcs = qse_mbsntombsdup (out.u.cpldup.ptr, out.u.cpldup.len, len, rtx->awk->mmgr);
wcs = qse_mbsntowcsdup (out.u.cpldup.ptr, out.u.cpldup.len, len, rtx->awk->mmgr);
QSE_AWK_FREE (rtx->awk, out.u.cpldup.ptr);
return wcs;
#else

View File

@ -104,6 +104,8 @@ void* qse_dir_getxtn (qse_dir_t* dir)
int qse_dir_init (qse_dir_t* dir, qse_mmgr_t* mmgr, const qse_char_t* path, int flags)
{
int n;
QSE_MEMSET (dir, 0, QSE_SIZEOF(*dir));
dir->mmgr = mmgr;
@ -120,7 +122,14 @@ int qse_dir_init (qse_dir_t* dir, qse_mmgr_t* mmgr, const qse_char_t* path, int
dir->h = INVALID_HANDLE_VALUE;
#endif
return reset_to_path (dir, path);
n = reset_to_path (dir, path);
if (n <= -1)
{
qse_mbs_fini (&dir->mbuf);
qse_str_fini (&dir->tbuf);
}
return n;
}
static void close_dir_safely (qse_dir_t* dir)
@ -384,6 +393,7 @@ static int reset_to_path (qse_dir_t* dir, const qse_char_t* path)
}
}
#endif
if (dp == QSE_NULL) return -1;
dir->dp = dp;
return 0;