From fa201229f7544b02711a35d18f1032fa3c0cb70c Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 19 Jun 2022 18:39:57 +0200 Subject: [PATCH] Close file on error --- source/devoptab/devoptab_fsa_open.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/devoptab/devoptab_fsa_open.cpp b/source/devoptab/devoptab_fsa_open.cpp index 37d3761..6a49b81 100644 --- a/source/devoptab/devoptab_fsa_open.cpp +++ b/source/devoptab/devoptab_fsa_open.cpp @@ -85,6 +85,9 @@ int __fsa_open(struct _reent *r, if (status < 0) { DEBUG_FUNCTION_LINE_ERR("FSAGetPosFile(0x%08X, 0x%08X, 0x%08X) failed: %s", deviceData->clientHandle, fd, &file->offset, FSAGetStatusStr(status)); r->_errno = __fsa_translate_error(status); + if (FSACloseFile(deviceData->clientHandle, fd) < 0) { + DEBUG_FUNCTION_LINE_ERR("FSACloseFile(0x%08X, 0x%08X) failed: %s", deviceData->clientHandle, fd, FSAGetStatusStr(status)); + } return -1; } }