FreeRDP-WebConnect icon indicating copy to clipboard operation
FreeRDP-WebConnect copied to clipboard

casting issue Please advice

Open Joseph1977 opened this issue 11 years ago • 1 comments

I see weird things which not make science:

void Primary::PatBlt(rdpContext ctx, PATBLT_ORDER po) { HCLRCONV hclrconv = reinterpret_cast<wsgContext *>(ctx)->clrconv; }

If you look at wsgContext you will see that rdpContext is one of its params:

typedef struct { /** * FreeRDP's original portion. _/ rdpContext p; /* * Pointer to the main RDP handler. / RDP *pRDP; /* * Pointer to the corresponding Update API module. / Update *pUpdate; /* * Pointer to the corresponding Primary API module. / Primary *pPrimary; /* * The current color space conversion parameter. */ HCLRCONV clrconv; } wsgContext;

So HOW you can cast struct A to struct B when struct B include A ???!!!!

simply cast small struct A (lets say 100 bytes) to bigger struct B (lets say 1000 bytes), mean the only first 100 bytes in struct B will have data but all the other 900 byes will be garbage or zero, correct?

this mean hclrconv will be garbage as reinterpret_cast(ctx)->clrconv is garbage, right?

Joseph1977 avatar Jun 16 '14 17:06 Joseph1977

To help in troubleshooting, can you please add a link to the code on github where you saw the issue?

Pasting directly the code here does not help much.

Thanks!

alexpilotti avatar Jun 28 '14 21:06 alexpilotti