diff --git a/src/posix/platform/settings.cpp b/src/posix/platform/settings.cpp index 73925fe21500..a0ccd39f0acb 100644 --- a/src/posix/platform/settings.cpp +++ b/src/posix/platform/settings.cpp @@ -474,12 +474,18 @@ otError PlatformSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex, } rval = write(swapFd, &key, sizeof(key)); - assert(rval == sizeof(key)); - VerifyOrDie(rval == sizeof(key), OT_EXIT_FAILURE); + if(rval != sizeof(key)) + { + swapDiscard(aInstance, swapFd); + VerifyOrDie(rval == sizeof(key), OT_EXIT_FAILURE); + } rval = write(swapFd, &length, sizeof(length)); - assert(rval == sizeof(length)); - VerifyOrDie(rval == sizeof(length), OT_EXIT_FAILURE); + if(rval != sizeof(length)) + { + swapDiscard(aInstance, swapFd); + VerifyOrDie(rval == sizeof(length), OT_EXIT_FAILURE); + } swapWrite(aInstance, swapFd, length); }