Skip to content

Commit

Permalink
Merge pull request #160 from nvaccess/getProgramPathBufferOverrun
Browse files Browse the repository at this point in the history
Stop buffer overrun in lou_getProgramPath, and also free memory after…
  • Loading branch information
egli committed Jun 16, 2016
2 parents 7e69d72 + fb65ff0 commit 5d4a603
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions liblouis/compileTranslationTable.c
Expand Up @@ -88,7 +88,9 @@ lou_getProgramPath ()
buffer = reallocWrapper (buffer, size <<= 1);

{
DWORD length = GetModuleFileName (handle, buffer, size);
// As the "UNICODE" Windows define may have been set at compilation,
// This call must be specifically GetModuleFilenameA as further code expects it to be single byte chars.
DWORD length = GetModuleFileNameA (handle, buffer, size);

if (!length)
{
Expand Down Expand Up @@ -4947,8 +4949,11 @@ getTablePath()
"tables");
#ifdef _WIN32
path = lou_getProgramPath ();
if (path != NULL && path[0] != '\0')
cp += sprintf (cp, ",%s%s", path, "\\share\\liblouis\\tables");
if (path != NULL) {
if(path[0] != '\0')
cp += sprintf (cp, ",%s%s", path, "\\share\\liblouis\\tables");
free(path);
}
#else
cp += sprintf (cp, ",%s", TABLESDIR);
#endif
Expand Down

0 comments on commit 5d4a603

Please sign in to comment.