bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

posix_spawn_file_actions_destroy: fix a crash


From: Bruno Haible
Subject: posix_spawn_file_actions_destroy: fix a crash
Date: Tue, 28 Apr 2020 12:31:31 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; )

Calling free() on a wrong value can produce a crash.


2020-04-28  Bruno Haible  <address@hidden>

        posix_spawn_file_actions_destroy: Fix a crash (bug from 2019-06-10).
        * lib/spawn_faction_destroy.c (posix_spawn_file_actions_destroy): Don't
        access elements of the wrong union member.

diff --git a/lib/spawn_faction_destroy.c b/lib/spawn_faction_destroy.c
index 906797b..e9985f4 100644
--- a/lib/spawn_faction_destroy.c
+++ b/lib/spawn_faction_destroy.c
@@ -42,9 +42,11 @@ posix_spawn_file_actions_destroy (posix_spawn_file_actions_t 
*file_actions)
       switch (sa->tag)
         {
         case spawn_do_open:
-        case spawn_do_chdir:
           free (sa->action.open_action.path);
           break;
+        case spawn_do_chdir:
+          free (sa->action.chdir_action.path);
+          break;
         default:
           /* No cleanup required.  */
           break;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]