diff options
author | Garrett Regier <garrettregier@gmail.com> | 2013-11-12 22:52:51 -0800 |
---|---|---|
committer | Garrett Regier <garrettregier@gmail.com> | 2013-11-12 22:52:51 -0800 |
commit | 438c2c12ebb71f2fc0e419c2fc9239d16601e76b (patch) | |
tree | 73346913363f70ddddf086a13ad81e73d19a4517 | |
parent | 37a8556065119c0e8d1a495b88dd54a869cbfaf6 (diff) | |
download | libpeas-438c2c12ebb71f2fc0e419c2fc9239d16601e76b.tar.gz |
Fix incorrect free
When prgname is NULL we would try to free a constant string.
-rw-r--r-- | 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 |