File: copy-string-returned-by-PyUnicode_AsUTF8.patch

package info (click to toggle)
nemo-python 5.6.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 384 kB
  • sloc: xml: 1,732; ansic: 795; python: 157; makefile: 9
file content (28 lines) | stat: -rw-r--r-- 1,148 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 7a3bf0666869dad4a3656692ffb236195b76cfbb Mon Sep 17 00:00:00 2001
From: Michael Webster <miketwebster@gmail.com>
Date: Wed, 18 Jan 2023 10:09:08 -0500
Subject: [PATCH] nemo-python-object.c: Copy the string returned by
 PyUnicode_AsUTF8.

Before python3.7, this returned a copy of its string. Now it returns
only a pointer, so the string must be copied before Py_XDECREF frees
the python object.

https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUTF8
---
 src/nemo-python-object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nemo-python-object.c b/nemo-python/src/nemo-python-object.c
index 0c1c9a7d..ec0e4717 100644
--- a/src/nemo-python-object.c
+++ b/src/nemo-python-object.c
@@ -169,7 +169,7 @@ nemo_python_object_get_name_and_desc (NemoNameAndDescProvider *provider)
                                 " must return a sequence of strings");
                 goto beach;
             }
-            ret = g_list_append (ret, (gchar *) PyUnicode_AsUTF8(py_item));
+            ret = g_list_append (ret, g_strdup ((gchar *) PyUnicode_AsUTF8(py_item)));
             Py_DECREF(py_item);
         }
  beach: