Fix unchecked pointer reference when adding sitedirs to sys.path.

This is a bugfix against the 2.28c release.
This commit is contained in:
Stephen Swaney
2003-10-19 06:26:32 +00:00
parent 56ad0d31b9
commit c19d84f89e

View File

@@ -199,31 +199,47 @@ void init_syspath(void)
syspath_append(p); /* append to module search path */
}
/* sds */
/* bring in the site module so we can add site-package dirs to sys.path */
/*
* bring in the site module so we can add
* site-package dirs to sys.path
*/
mod = PyImport_ImportModule("site"); /* new ref */
if (mod) {
PyObject* item;
int size, index;
int size = 0;
int index;
/* get the value of 'sitedirs' from the module */
/* the ref man says GetDict() never fails!!! */
d = PyModule_GetDict (mod); /* borrowed ref */
p = PyDict_GetItemString (d, "sitedirs"); /* borrowed ref */
/* append each item in sitedirs list to path */
size = PyList_Size (p);
if( p ) { /* we got our string */
/* append each item in sitedirs list to path */
size = PyList_Size (p);
for (index = 0; index < size; index++) {
item = PySequence_GetItem (p, index); /* new ref */
syspath_append (item);
for (index = 0; index < size; index++) {
item = PySequence_GetItem (p, index); /* new ref */
if( item )
syspath_append (item);
}
}
Py_DECREF(mod);
}
else PyErr_Clear();
else { /* import 'site' failed */
PyErr_Clear();
printf("sys_init:warning - no sitedirs added from site module.\n");
}
/*
* initialize the sys module
* set sys.executable to the Blender exe
* set argv[0] to the Blender exe
*/
/* set sys.executable to the Blender exe */
mod = PyImport_ImportModule("sys"); /* new ref */
if (mod) {