Fix sigchainlib's implementation of sigaction

  Correctly handles the case when old_action == new_action

Bug: 18740478
Change-Id: I97092318439e4f6f0a2513d4336496c72f8c5599
(cherry picked from commit 797a29b334f2d311135602bf5204ae8b890f4a14)
diff --git a/sigchainlib/sigchain.cc b/sigchainlib/sigchain.cc
index 601e321..2eb518c 100644
--- a/sigchainlib/sigchain.cc
+++ b/sigchainlib/sigchain.cc
@@ -170,12 +170,13 @@
   // Note that we check that the signal number is in range here.  An out of range signal
   // number should behave exactly as the libc sigaction.
   if (signal > 0 && signal < _NSIG && user_sigactions[signal].IsClaimed()) {
-    if (old_action != NULL) {
-      *old_action = user_sigactions[signal].GetAction();
-    }
+    struct sigaction saved_action = user_sigactions[signal].GetAction();
     if (new_action != NULL) {
       user_sigactions[signal].SetAction(*new_action, false);
     }
+    if (old_action != NULL) {
+      *old_action = saved_action;
+    }
     return 0;
   }