[checks,return] fix various unchecked return values

This commit is contained in:
Armin Novak
2026-03-02 18:46:22 +01:00
parent 103e0907cc
commit b724ba546d
16 changed files with 50 additions and 30 deletions

View File

@@ -822,7 +822,6 @@ extern "C"
WINPR_API void MessagePipe_Free(wMessagePipe* pipe);
WINPR_ATTR_MALLOC(MessagePipe_Free, 1)
WINPR_ATTR_NODISCARD
WINPR_API wMessagePipe* MessagePipe_New(void);
/* Publisher/Subscriber Pattern */

View File

@@ -653,7 +653,10 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
/* Check the BOM (Byte Order Mark) */
if ((pSrcData.cpb[0] == 0xFE) && (pSrcData.cpb[1] == 0xFF))
ByteSwapUnicode(pSrcData.pv, (SrcSize / 2));
{
if (!ByteSwapUnicode(pSrcData.pv, (SrcSize / 2)))
goto fail;
}
/* Check if we have WCHAR, convert to UTF-8 */
if ((pSrcData.cpb[0] == 0xFF) && (pSrcData.cpb[1] == 0xFE))

View File

@@ -104,7 +104,8 @@ static struct synthetic_file* make_synthetic_file(const WCHAR* local_name, const
{
const size_t len = _wcslen(file->remote_name);
PathCchConvertStyleW(file->remote_name, len, PATH_STYLE_WINDOWS);
if (S_OK != PathCchConvertStyleW(file->remote_name, len, PATH_STYLE_WINDOWS))
goto fail;
}
file->dwFileAttributes = fd.dwFileAttributes;

View File

@@ -18,6 +18,7 @@
*/
#include <winpr/config.h>
#include <winpr/assert.h>
#include <winpr/crt.h>
#include <winpr/sysinfo.h>
@@ -34,6 +35,7 @@
void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode)
{
WINPR_ASSERT(pipe);
MessageQueue_PostQuit(pipe->In, nExitCode);
MessageQueue_PostQuit(pipe->Out, nExitCode);
}
@@ -44,27 +46,23 @@ void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode)
wMessagePipe* MessagePipe_New(void)
{
wMessagePipe* pipe = nullptr;
pipe = (wMessagePipe*)malloc(sizeof(wMessagePipe));
wMessagePipe* pipe = (wMessagePipe*)calloc(1, sizeof(wMessagePipe));
if (!pipe)
return nullptr;
pipe->In = MessageQueue_New(nullptr);
if (!pipe->In)
goto error_in;
goto fail;
pipe->Out = MessageQueue_New(nullptr);
if (!pipe->Out)
goto error_out;
goto fail;
return pipe;
error_out:
MessageQueue_Free(pipe->In);
error_in:
free(pipe);
fail:
MessagePipe_Free(pipe);
return nullptr;
}