Skip to content

Commit

Permalink
Fixed leak in tests.c according to valgrind's run
Browse files Browse the repository at this point in the history
  • Loading branch information
gfoidl committed Apr 9, 2020
1 parent e7df0cc commit d7cb2be
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libraries/Native/Unix/System.Native/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
struct state
{
HostEntry entry;
char* hostName;
int errorCode;
sem_t semaphore;
};
Expand Down Expand Up @@ -65,6 +64,7 @@ int main(int argc, char** argv)
}

struct state state;
memset(&state.entry, 0, sizeof(HostEntry));
sem_init(&state.semaphore, 0, 0);

int error = SystemNative_GetHostEntryForNameAsync((uint8_t*)hostName, &state.entry, callback);
Expand All @@ -80,6 +80,8 @@ int main(int argc, char** argv)
sem_wait(&state.semaphore);
sem_destroy(&state.semaphore);

SystemNative_FreeHostEntry(&state.entry);

printf("(%lu) main: exit, errorCode: %d\n", pthread_self(), state.errorCode);

return state.errorCode;
Expand Down

0 comments on commit d7cb2be

Please sign in to comment.