common: Fix error handling.
authorJustus Winter <justus@g10code.com>
Mon, 5 Sep 2016 13:33:51 +0000 (15:33 +0200)
committerJustus Winter <justus@g10code.com>
Mon, 5 Sep 2016 15:26:50 +0000 (17:26 +0200)
* common/exechelp-posix.c (store_result): Use xtrymalloc.
(gnupg_wait_processes): Likewise, and check result.

Signed-off-by: Justus Winter <justus@g10code.com>
common/exechelp-posix.c

index 32c4203..56380f2 100644 (file)
@@ -610,7 +610,7 @@ store_result (pid_t pid, int exitcode)
 {
   struct terminated_child *c;
 
-  c = xmalloc (sizeof *c);
+  c = xtrymalloc (sizeof *c);
   if (c == NULL)
     return gpg_err_code_from_syserror ();
 
@@ -660,7 +660,11 @@ gnupg_wait_processes (const char **pgmnames, pid_t *pids, size_t count,
   int *dummy = NULL;
 
   if (r_exitcodes == NULL)
-    dummy = r_exitcodes = xmalloc (sizeof *r_exitcodes * count);
+    {
+      dummy = r_exitcodes = xtrymalloc (sizeof *r_exitcodes * count);
+      if (dummy == NULL)
+        return gpg_err_code_from_syserror ();
+    }
 
   for (i = 0, left = count; i < count; i++)
     {