[libpeas] Fix incorrect free
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Fix incorrect free
- Date: Wed, 13 Nov 2013 08:36:20 +0000 (UTC)
commit 438c2c12ebb71f2fc0e419c2fc9239d16601e76b
Author: Garrett Regier <garrettregier gmail com>
Date: Tue Nov 12 22:52:51 2013 -0800
Fix incorrect free
When prgname is NULL we would try to free a constant string.
loaders/python/peas-plugin-loader-python.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index cdfcee7..059c626 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -374,9 +374,9 @@ peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
PyObject *mdict, *gettext, *install, *gettext_args;
const gchar *prgname;
#if PY_VERSION_HEX < 0x03000000
- const char *argv[] = { "", NULL };
+ const char *argv[] = { NULL, NULL };
#else
- wchar_t *argv[] = { L"", NULL };
+ wchar_t *argv[] = { NULL, NULL };
#endif
/* We are trying to initialize Python for the first time,
@@ -413,14 +413,13 @@ peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
}
prgname = g_get_prgname ();
- if (prgname != NULL)
- {
+ prgname = prgname == NULL ? "" : prgname;
+
#if PY_VERSION_HEX < 0x03000000
- argv[0] = prgname;
+ argv[0] = prgname;
#else
- argv[0] = peas_wchar_from_str (prgname);
+ argv[0] = peas_wchar_from_str (prgname);
#endif
- }
/* See http://docs.python.org/c-api/init.html#PySys_SetArgvEx */
#if PY_VERSION_HEX < 0x02060600
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]