From 90d4524a8680b1567343f4c2c3fd8c720596cd03 Mon Sep 17 00:00:00 2001
From: Chris Broekema <broekema@astron.nl>
Date: Mon, 11 Jan 2010 12:41:12 +0000
Subject: [PATCH] Bug #1011: check posix_memalign return values

---
 RTCP/Interface/include/Interface/StreamableData.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/RTCP/Interface/include/Interface/StreamableData.h b/RTCP/Interface/include/Interface/StreamableData.h
index ca3ab7b1c6f..fe332abb6bd 100644
--- a/RTCP/Interface/include/Interface/StreamableData.h
+++ b/RTCP/Interface/include/Interface/StreamableData.h
@@ -120,7 +120,9 @@ inline void StreamableData::write(Stream *str, bool withSequenceNumber, unsigned
       void *sn_buf;
       uint32_t sn = sequenceNumber;
 
-      posix_memalign(&sn_buf, align, align);
+      if (posix_memalign(&sn_buf, align, align) != 0) {
+	THROW(InterfaceException,"could not allocate data");
+      }
 
       try {
         dataConvert(BigEndian, &sn, 1);
@@ -144,7 +146,9 @@ inline void StreamableData::write(Stream *str, bool withSequenceNumber, unsigned
       if (align < sizeof(uint32_t)) THROW(AssertError, "Sizeof alignment < sizeof sequencenumber");
 
       void *sn_buf;
-      posix_memalign(&sn_buf, align, align);
+      if (posix_memalign(&sn_buf, align, align) != 0) {
+	THROW(InterfaceException,"could not allocate data");
+      }
 
       try {
         memcpy(sn_buf, &sequenceNumber, sizeof sequenceNumber);
-- 
GitLab