* engine-gpgsm.c (_gpgme_gpgsm_new): Save the result of a first
authorWerner Koch <wk@gnupg.org>
Fri, 22 Nov 2002 15:02:37 +0000 (15:02 +0000)
committerWerner Koch <wk@gnupg.org>
Fri, 22 Nov 2002 15:02:37 +0000 (15:02 +0000)
setlocale before doing another setlocale.

branches/gpgme-0-3-branch/gpgme/ChangeLog
branches/gpgme-0-3-branch/gpgme/engine-gpgsm.c

index 78ac092ca2b772835c24dd94160f73712e7e993d..925f20c218d32455478d42d714c08bf050e5d0de 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-22  Werner Koch  <wk@gnupg.org>
+
+       * engine-gpgsm.c (_gpgme_gpgsm_new): Save the result of a first
+       setlocale before doing another setlocale.
+
 2002-11-21  Marcus Brinkmann  <marcus@g10code.de>
 
        * verify.c (_gpgme_verify_status_handler): Treat
index 6d98a9d529a7489c945f4f00084751ea088cc84d..41e63f5779bd0c419c8f46faf823b4bcb167a787 100644 (file)
@@ -450,7 +450,17 @@ _gpgme_gpgsm_new (GpgsmObject *r_gpgsm)
              goto leave;
            }
        }
+
       old_lc = setlocale (LC_CTYPE, NULL);
+      if (old_lc)
+        {
+          old_lc = strdup (old_lc);
+          if (!old_lc)
+            {
+              err = GPGME_Out_Of_Core;
+              goto leave;
+            }
+        }
       dft_lc = setlocale (LC_CTYPE, "");
       if (dft_lc)
        {
@@ -458,19 +468,32 @@ _gpgme_gpgsm_new (GpgsmObject *r_gpgsm)
            err = mk_error (Out_Of_Core);
          else
            {
-             err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
-                                    NULL);
+             err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL,
+                                     NULL, NULL, NULL, NULL);
              free (optstr);
              if (err)
                err = map_assuan_error (err);
            }
        }
       if (old_lc)
-       setlocale (LC_CTYPE, old_lc);
+        {
+          setlocale (LC_CTYPE, old_lc);
+          free (old_lc);
+        }
       if (err)
        goto leave;
 
+
       old_lc = setlocale (LC_MESSAGES, NULL);
+      if (old_lc)
+        {
+          old_lc = strdup (old_lc);
+          if (!old_lc)
+            {
+              err = GPGME_Out_Of_Core;
+              goto leave;
+            }
+        }
       dft_lc = setlocale (LC_MESSAGES, "");
       if (dft_lc)
        {
@@ -486,7 +509,10 @@ _gpgme_gpgsm_new (GpgsmObject *r_gpgsm)
            }
        }
       if (old_lc)
-       setlocale (LC_MESSAGES, old_lc);
+        {
+          setlocale (LC_MESSAGES, old_lc);
+          free (old_lc);
+        }
       if (err)
        goto leave;
     }