Skip to content

Commit

Permalink
convert(): plug potential memory leak
Browse files Browse the repository at this point in the history
When the result of conversion is identical to the original argument, we
should make sure that the temporary buffer was released.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 14, 2017
1 parent 903eac5 commit 7212cb8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions winsup/cygwin/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3464,6 +3464,10 @@ arg_heuristic_with_exclusions (char const * const arg, char const * exclusions,
// Don't allocate memory if no conversion happened.
if (!strcmp (arg, stack_path))
{
if (arg != stack_path)
{
free (stack_path);
}
return ((char *)arg);
}
arg_result = (char *)realloc (stack_path, strlen (stack_path)+1);
Expand Down

0 comments on commit 7212cb8

Please sign in to comment.