View Issue Details

IDProjectCategoryView StatusLast Update
0000716FreeCADBugpublic2012-05-23 11:04
Reporterflelchuk Assigned To 
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionfixed 
Product Version0.12 
Fixed in Version0.13 
Summary0000716: src/Tools/PyTools.c: strange assignment and a memory leak
DescriptionIn src/Tools/PyTools.c it reads:

00375 const char *PP_Init(const char *modname) {
00376 Py_Initialize(); /* init python if needed */
00377 //#ifdef FC_OS_LINUX /* cannot convert `const char *' to `char *' in assignment */
00378 if (modname!=NULL) return modname;
00379 { /* we assume here that the caller frees allocated memory */
00380 char* __main__=(char *)malloc(sizeof("__main__"));
00381 return __main__="__main__";
00382 }
00383 //#else
00384 // return modname == NULL ? "__main__" : modname; /* default to '__main__' */
00385 //#endif
00386 }

What's in line 381 does not really make sense.
Instead of making a copy, the only reference to the previously malloc'd memory is lost.

I'd suggest to remove line 380 and replace line 381 with

return "__main__";

Best Regards,

Felix
TagsNo tags attached.
FreeCAD Information

Activities

wmayer

2012-05-23 11:04

administrator   ~0002078

Done.

Issue History

Date Modified Username Field Change
2012-05-21 19:15 flelchuk New Issue
2012-05-23 11:04 wmayer Note Added: 0002078
2012-05-23 11:04 wmayer Status new => closed
2012-05-23 11:04 wmayer Resolution open => fixed
2012-05-23 11:04 wmayer Fixed in Version => 0.13