Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed memory leaks

  • Loading branch information...
commit ad8709afe6c2dda59e675087a1e97de08e26e481 1 parent 3245fef
Andre d authored

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 2 casecorrectpath.cpp
8 casecorrectpath.cpp
@@ -33,11 +33,15 @@ std::string GetCaseCorrectPath(std::string input_path){
33 33 char* correct_case_buf = new char[kPathBufferSize];
34 34 GetShortPathName(input_path.c_str(), short_path, kPathBufferSize);
35 35 GetLongPathName(short_path, correct_case_buf, kPathBufferSize);
  36 + std::string corrected = std::string(correct_case_buf);
36 37 delete short_path;
37   - return std::string(correct_case_buf);
  38 + delete correct_case_buf;
  39 + return corrected;
38 40 #else // Correct case using realpath() and cut off working directory
39 41 std::ptrdiff_t num_dirs = std::count(input_path.begin(), input_path.end(), '/');
40   - std::string path(realpath(input_path.c_str(), NULL));
  42 + char* real_path = realpath(input_path.c_str(), NULL);
  43 + std::string path(real_path);
  44 + free(real_path);
41 45 return path.substr(FindNthCharFromBack(path,'/',num_dirs+1)+1);
42 46 #endif
43 47 }

0 comments on commit ad8709a

Please sign in to comment.
Something went wrong with that request. Please try again.