From 6c37c44ee006b3ed9957e5f3664c7063f319d565 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Thu, 16 May 2019 09:23:20 +0300 Subject: [PATCH] Minor fix. * src/wordsplit.c (_wsplt_seterr_sub): Propagate error context. --- src/wordsplit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wordsplit.c b/src/wordsplit.c index 6dba914..48312bb 100644 --- a/src/wordsplit.c +++ b/src/wordsplit.c @@ -198,8 +198,10 @@ _wsplt_subsplit (struct wordsplit *wsp, struct wordsplit *wss, static void _wsplt_seterr_sub (struct wordsplit *wsp, struct wordsplit *wss) { + /* Clear user-defined error */ if (wsp->ws_errno == WRDSE_USERERR) free (wsp->ws_usererr); + /* Copy error state */ wsp->ws_errno = wss->ws_errno; if (wss->ws_errno == WRDSE_USERERR) { @@ -207,6 +209,10 @@ _wsplt_seterr_sub (struct wordsplit *wsp, struct wordsplit *wss) wss->ws_errno = WRDSE_EOF; wss->ws_usererr = NULL; } + /* Copy error context */ + free (wsp->ws_errctx); + wsp->ws_errctx = wss->ws_errctx; + wss->ws_errctx = NULL; } static void