summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lrtp.cc17
1 files changed, 14 insertions, 3 deletions
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<csrc_t> 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;
}