]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix a minor memory leak in VIX Listfiles().
authorJohn Wolfe <jwolfe@vmware.com>
Tue, 13 Oct 2020 21:00:59 +0000 (14:00 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Tue, 13 Oct 2020 21:00:59 +0000 (14:00 -0700)
The GError structure is not cleared in an error code path, which
leads to a minor memory leak.  Explicitly call g_clear_error().

open-vm-tools/services/plugins/vix/vixTools.c

index 79ad9cc15b22c627c46db6d7430c4606f18e8ad6..8b4650468d7288364b18d6b7143f9c215764873b 100644 (file)
@@ -6590,7 +6590,6 @@ VixToolsListFiles(VixCommandRequestHeader *requestMsg,    // IN
    int remaining = 0;
    int numResults;
    GRegex *regex = NULL;
-   GError *gErr = NULL;
    char *pathName;
    VMAutomationRequestParser parser;
 
@@ -6644,11 +6643,13 @@ VixToolsListFiles(VixCommandRequestHeader *requestMsg,    // IN
            index, maxResults, (int) offset);
 
    if (pattern) {
+      GError *gErr = NULL;
       regex = g_regex_new(pattern, 0, 0, &gErr);
       if (!regex) {
          g_warning("%s: bad regex pattern '%s' (%s);"
                    "failing with INVALID_ARG\n",
                    __FUNCTION__, pattern, gErr ? gErr->message : "");
+         g_clear_error(&gErr);
          err = VIX_E_INVALID_ARG;
          goto abort;
       }