From 8da2861036b14da10498635d2c38cc876e83ac89 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 10 Dec 2013 15:02:25 +0100 Subject: Get rid of var stack alloc (doesn't work with msvc.) --- src/lrtp.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lrtp.cc b/src/lrtp.cc index 9447032..da02083 100644 --- a/src/lrtp.cc +++ b/src/lrtp.cc @@ -273,7 +273,7 @@ int lrtp_unpack(struct lrtp_t *lrtp, const char *packet, size_t size) // TODO: Check lrtp magic word - char pkg[size]; + char *pkg = (char*)malloc(size); memcpy(pkg, packet, size); int ret = 0; @@ -283,6 +283,7 @@ int lrtp_unpack(struct lrtp_t *lrtp, const char *packet, size_t size) if(ret < 0) { printf("lrtp_unpack::decrypt error: %d\n", ret); + free(pkg); return -1; } @@ -292,13 +293,20 @@ int lrtp_unpack(struct lrtp_t *lrtp, const char *packet, size_t size) RTP rtp; rtp.fromPacket(pkg, size); std::list csrcs = rtp.getCSrcs(); - if(csrcs.size() == 0) return -UNPACK_MISSING_CSRC; - if(csrcs.size() > 1) return -UNPACK_TOO_MANY_CSRCS; + if(csrcs.size() == 0) { + free(pkg); + return -UNPACK_MISSING_CSRC; + } + if(csrcs.size() > 1) { + free(pkg); + return -UNPACK_TOO_MANY_CSRCS; + } csrc_t csrc = *csrcs.begin(); struct lrtp_profile_t *profile = NULL; if(lrtp->profiles.find(csrc) == lrtp->profiles.end()) { + free(pkg); return -UNPACK_MISSING_PROFILE; } @@ -309,6 +317,7 @@ int lrtp_unpack(struct lrtp_t *lrtp, const char *packet, size_t size) if(ret < 0) { printf("lrtp_unpack::Profile unpack failed: %d\n", ret); + free(pkg); return -1; } @@ -321,6 +330,8 @@ int lrtp_unpack(struct lrtp_t *lrtp, const char *packet, size_t size) lrtp->framelist.splice(lrtp->framelist.end(), framelist); + free(pkg); + return ret; } -- cgit v1.2.3