OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-link-grammar commits / 9dd0517

make_dirpath(): Bugfix dir memory leak on MS Windows
9dd0517efc87d70a2af221896def845122950b69
by ampli <amirpli@gmail.com> · 2024-05-28T21:47:48.000Z

Changed files (1) +4 -3

link-parser/lg_xdg.c +4 -3
……@@ -84,22 +84,23 @@ static bool is_sep(int c)
8484 */
8585static bool make_dirpath(const char *path)
8686{
87 char *dir = strdup(path);
8887 struct stat sb;
8988
9089#if defined(_WIN32) || defined(__CYGWIN__)
9190 // Skip Windows UNC path \\X
92 if (is_sep(dir[0]) && is_sep(dir[1]))
91 if (is_sep(path[0]) && is_sep(path[1]))
9392 {
9493 const char *p;
9594
9695 // Start from the root or network share
97 for (p = dir + 2; *p != '\0'; p++)
96 for (p = path + 2; *p != '\0'; p++)
9897 if (is_sep(*p)) break;
9998 if (*p == '\0') return true; // No further subdirectories
10099 }
101100#endif
102101
102 char *dir = strdup(path);
103
103104 for (char *p = dir+1; '\0' != *p; p++)
104105 {
105106 char sep = *p;