]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/python] Ensure locale is restored in do_start_initialization
authorTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2024 16:34:50 +0000 (17:34 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2024 16:34:50 +0000 (17:34 +0100)
commit8a7f13063a6d5314cfde5b4f1dc49afa2922cf8c
tree2c1d23a7ef8efb6bc3b227ae28e66c44c047003e
parent461248c1433714584060fd3a41efe28088aa855b
[gdb/python] Ensure locale is restored in do_start_initialization

I noticed in do_start_initialization:
...
  std::string oldloc = setlocale (LC_ALL, NULL);
  setlocale (LC_ALL, "");
  ...
  if (count == (size_t) -1)
    {
      fprintf (stderr, "Could not convert python path to string\n");
      return false;
    }
  setlocale (LC_ALL, oldloc.c_str ());
...
that the old locale is not restored if the "return false" is triggered.

Fix this by using SCOPE_EXIT.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/python/python.c