Skip to content

Commit

Permalink
fix invalid stack allocation by using alloca
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Apr 13, 2020
1 parent 1635f28 commit f78cdeb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/spice.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ Place, Suite 330, Boston, MA 02111-1307 USA

#define SPICE_PACKET(htype, payloadType, extraData) \
({ \
uint8_t packet[sizeof(ssize_t) + sizeof(SpiceMiniDataHeader) + sizeof(payloadType)]; \
ssize_t * sz = (ssize_t*)packet; \
uint8_t * packet = alloca(sizeof(ssize_t) + sizeof(SpiceMiniDataHeader) + \
sizeof(payloadType)); \
ssize_t * sz = (ssize_t*)packet; \
SpiceMiniDataHeader * header = (SpiceMiniDataHeader *)(sz + 1); \
*sz = sizeof(SpiceMiniDataHeader) + sizeof(payloadType); \
header->type = (htype); \
Expand Down

0 comments on commit f78cdeb

Please sign in to comment.