]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Call g_clear_error(&err) after g_locale_from_utf8() fails.
authorVMware, Inc <>
Tue, 26 Apr 2011 21:15:06 +0000 (14:15 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 26 Apr 2011 21:15:06 +0000 (14:15 -0700)
After catching an error from g_locale_from_utf8() the error structure
is not freed. This results in a warning from GLib when we later call
g_spawn_async() with the same (now populated) error parameter.

While we're in here copy the debug message from the Windows version of
PowerOpsScriptCallback() so that the exit code of the power script is
logged.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/powerOps/powerOps.c

index 735a3ac0edaf53ec11995523a8f9206ba3fc5834..15d73dbe3b2abb252d727c055e92bd035cc54d03 100644 (file)
@@ -307,7 +307,7 @@ PowerOpsRunScript(PowerOpState *state,
  * Callback for when the script process finishes on POSIX systems.
  *
  * @param[in]  pid         Child pid.
- * @param[in]  status      Exit status of script.
+ * @param[in]  exitcode    Exit status of script.
  * @param[in]  _state      Plugin state.
  *
  * @return FALSE.
@@ -315,14 +315,16 @@ PowerOpsRunScript(PowerOpState *state,
 
 static gboolean
 PowerOpsScriptCallback(GPid pid,
-                       gint status,
+                       gint exitcode,
                        gpointer _state)
 {
    PowerOpState *state = _state;
+   gboolean success = exitcode == 0;
 
    ASSERT(state->pid != INVALID_PID);
 
-   PowerOpsStateChangeDone(_state, status == 0);
+   g_debug("Script exit code: %d, success = %d\n", exitcode, success);
+   PowerOpsStateChangeDone(_state, success);
    g_spawn_close_pid(state->pid);
    state->pid = INVALID_PID;
    return FALSE;
@@ -352,6 +354,7 @@ PowerOpsRunScript(PowerOpState *state,
    argv[0] = g_locale_from_utf8(script, -1, NULL, NULL, &err);
    if (err != NULL) {
       g_debug("Conversion error: %s\n", err->message);
+      g_clear_error(&err);
       /*
        * If we could not convert to current locate let's hope that
        * what we have is a useable script name and use it directly.