forked from bartvdbraak/blender
BGE: correct ftell use in LoadGlobalDict
This commit is contained in:
parent
f3434e5f82
commit
b2e5c017a1
@ -178,6 +178,11 @@ bool KX_GameActuator::Update()
|
|||||||
// obtain file size:
|
// obtain file size:
|
||||||
fseek (fp , 0 , SEEK_END);
|
fseek (fp , 0 , SEEK_END);
|
||||||
marshal_length = ftell(fp);
|
marshal_length = ftell(fp);
|
||||||
|
if (marshal_length == -1) {
|
||||||
|
printf("warning: could not read position of '%s'\n", mashal_path);
|
||||||
|
fclose(fp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
|
|
||||||
marshal_buffer = (char*) malloc (sizeof(char)*marshal_length);
|
marshal_buffer = (char*) malloc (sizeof(char)*marshal_length);
|
||||||
|
@ -356,7 +356,7 @@ static PyObject *gPyLoadGlobalDict(PyObject *)
|
|||||||
{
|
{
|
||||||
char marshal_path[512];
|
char marshal_path[512];
|
||||||
char *marshal_buffer = NULL;
|
char *marshal_buffer = NULL;
|
||||||
size_t marshal_length;
|
int marshal_length;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -367,7 +367,12 @@ static PyObject *gPyLoadGlobalDict(PyObject *)
|
|||||||
if (fp) {
|
if (fp) {
|
||||||
// obtain file size:
|
// obtain file size:
|
||||||
fseek (fp, 0, SEEK_END);
|
fseek (fp, 0, SEEK_END);
|
||||||
marshal_length = (size_t)ftell(fp);
|
marshal_length = ftell(fp);
|
||||||
|
if (marshal_length == -1) {
|
||||||
|
printf("Warning: could not read position of '%s'\n", marshal_path);
|
||||||
|
fclose(fp);
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
|
|
||||||
marshal_buffer = (char*)malloc (sizeof(char)*marshal_length);
|
marshal_buffer = (char*)malloc (sizeof(char)*marshal_length);
|
||||||
|
Loading…
Reference in New Issue
Block a user