amagnasco / xwpe

Upload of an abandoned ncurses-based programming environment
http://www.identicalsoftware.com/xwpe/
GNU General Public License v2.0
31 stars 7 forks source link

Misuse of pointer casting within `we_fl_unix.c` #86

Open gbonnema opened 7 years ago

gbonnema commented 7 years ago

In WpeCreateFileManager() of we_fl_unix.c we see the following lines (with other code in between):

FLBFFR *b ..... if ((b = (FLBFFR *) malloc (sizeof (FLBFFR))) == NULL) e_error (e_msg[ERR_LOWMEM], 1, control->colorset); ..... window->b = (we_buffer_t *) b;

And in subsequent WpeDrawFileManager() of we_fl_unix.c we see:

FLBFFR *b = (FLBFFR *) window->b;

The point is, that these functions misuse an existing pointer in we_buffer_t (or BFF) which is a pointer to a completely different struct : FLBFFR for the struct FLBFF and does not have the same contents at all!!

For now this works, but to me it seems to be bad design. From the names of the functions I derive that this is one of the newer refactors by Dennis Payne and other maintainers of that group.

I marked this as a question as well as a bug. To be determined whether and how to change.

P.S. introducing a label "design issue' would be a bood thing for such issues.