Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions source/liblocate/source/liblocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,9 @@ void getBundlePath(char ** path, unsigned int * pathLength)
}

// Copy contents to caller, create caller ownership
*path = executablePath;
if (pathLength != 0x0)
{
*pathLength = bundlePathLength;
}
copyToStringOutParameter(executablePath, bundlePathLength, path, pathLength);

free(executablePath);
}

void getModulePath(char ** path, unsigned int * pathLength)
Expand Down
5 changes: 5 additions & 0 deletions source/liblocate/source/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ unsigned char fileExists(const char * path, unsigned int pathLength)
{
(void)pathLength;

if (path == 0)
{
return 0;
}

#ifdef SYSTEM_WINDOWS

WIN32_FILE_ATTRIBUTE_DATA fileInfo;
Expand Down
15 changes: 15 additions & 0 deletions source/tests/liblocate-test/liblocate_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ TEST_F(liblocate_test, libPrefix_Return)
ASSERT_NE(nullptr, prefix);
EXPECT_STREQ("lib", prefix);
#endif

free(prefix);
}

TEST_F(liblocate_test, libExtension_NoReturn)
Expand Down Expand Up @@ -251,6 +253,8 @@ TEST_F(liblocate_test, libExtension_Return)
ASSERT_NE(nullptr, extension);
EXPECT_STREQ("so", extension);
#endif

free(extension);
}

TEST_F(liblocate_test, libExtensions_NoReturn)
Expand All @@ -265,6 +269,7 @@ TEST_F(liblocate_test, libExtensions_Return)
char ** extensions;
unsigned int * lengths;
unsigned int count;
unsigned int i;

libExtensions(&extensions, &lengths, &count);

Expand All @@ -290,6 +295,14 @@ TEST_F(liblocate_test, libExtensions_Return)
ASSERT_NE(nullptr, extensions[0]);
EXPECT_STREQ("so", extensions[0]);
#endif

for (i = 0; i < count; ++i)
{
free(extensions[i]);
}

free(lengths);
free(extensions);
}

TEST_F(liblocate_test, homeDir)
Expand All @@ -301,4 +314,6 @@ TEST_F(liblocate_test, homeDir)

EXPECT_NE(nullptr, dir);
EXPECT_LE(0, length);

free(dir);
}