Skip to content

Commit

Permalink
Merge pull request #1211 from skliper/fix1210-os_stat_handler_init
Browse files Browse the repository at this point in the history
Fix #1210, Set output in OS_stat handler
  • Loading branch information
astrogeco committed Jan 19, 2022
2 parents 17b7163 + 45ab4e1 commit cf01555
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 cf01555

Please sign in to comment.