From: Nirbheek Chauhan Date: Tue, 20 Aug 2019 08:51:17 +0000 (+0530) Subject: sctp: Fix crash on free() when using the MSVC binaries X-Git-Tag: accepted/tizen/unified/20220217.153506~2^2~10^2~9^2~12^2~2^2~90^2~1^2~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4af68aa58b4a67454efe18c0e36a126dfe982da;p=platform%2Fupstream%2Fgstreamer.git sctp: Fix crash on free() when using the MSVC binaries On Windows, if libusrsctp and gstreamer are built with different C runtimes (CRT), we cannot free memory allocated inside libusrsctp with the `free()` function from gstreamer's CRT. `usrsctp_freedumpbuffer()` simply calls `free()`, but because of the way DLLs work on Windows, it will always call the free function from the correct CRT. --- diff --git a/ext/sctp/sctpassociation.c b/ext/sctp/sctpassociation.c index 23be55f..430e9cc 100644 --- a/ext/sctp/sctpassociation.c +++ b/ext/sctp/sctpassociation.c @@ -686,7 +686,11 @@ receive_cb (struct socket *sock, union sctp_sockstore addr, void *data, if (flags & MSG_NOTIFICATION) { handle_notification (self, (const union sctp_notification *) data, datalen); - free (data); + /* We use this instead of a bare `free()` so that we use the `free` from + * the C runtime that usrsctp was built with. This makes a difference on + * Windows where libusrstcp and GStreamer can be linked to two different + * CRTs. */ + usrsctp_freedumpbuffer (data); } else { handle_message (self, data, datalen, rcv_info.rcv_sid, ntohl (rcv_info.rcv_ppid));