Skip to content

Commit

Permalink
Fix #1210, Set output in OS_stat handler
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Jan 18, 2022
1 parent 4cc6dbb commit 45ab4e1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ut-stubs/osapi-file-handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,20 @@ void UT_DefaultHandler_OS_TimedWrite(void *UserObj, UT_EntryKey_t FuncKey, const
void UT_DefaultHandler_OS_stat(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
os_fstat_t *filestats = UT_Hook_GetArgValueByName(Context, "filestats", os_fstat_t *);
size_t CopySize;
int32 Status;

UT_Stub_GetInt32StatusCode(Context, &Status);

if (Status == OS_SUCCESS)
{
UT_Stub_CopyToLocal(UT_KEY(OS_stat), filestats, sizeof(*filestats));
CopySize = UT_Stub_CopyToLocal(UT_KEY(OS_stat), filestats, sizeof(*filestats));

/* Ensure memory is set if not provided by test */
if (CopySize < sizeof(*filestats))
{
memset(filestats, 0, sizeof(*filestats));
}
}
}

Expand Down

0 comments on commit 45ab4e1

Please sign in to comment.