Thu, 01/12/2012 - 16:29
Forums:
Hello,
since sprintf does not allocate memory the lines:
char* name;
sprintf(name,"wire-on-face");
will probably lead to a crash. My fix is to declare name as a fixed-size array instead:
char name[128];
sprintf(name,"wire-on-face");
Pawel
Fri, 01/13/2012 - 02:15
what about
char *name = strdup("wire-on-face")
and if needed
free(name)
? I usually see as dangerous the fixed-size arrays...
Max
Fri, 01/13/2012 - 02:45
Egal, du kanst deine eigene gepasste OCC-Libs kompilieren
Fri, 01/13/2012 - 03:05
Hello Max,
the variable 'name' is still needed when the function exits and I was too lazy to look for the place where it is not needed any more ;)
Pawel
Fri, 01/13/2012 - 03:06
by the way, most of the problems reported today were found by cppcheck.
Pawel
Fri, 01/13/2012 - 08:21
Hi Pawel,
I confirm. I ran cppcheck-1.52 over the current OCE master branch and it reported some of the issues you reported. I fixed a few of them, created a dev branch on github, and included your fixes (see https://github.com/tpaviot/oce/commits/tp/QA-fixes).
Thomas
Mon, 01/30/2012 - 14:06
http://tracker.dev.opencascade.org/view.php?id=22935