diff --git a/linphone/oRTP/include/ortp/port.h b/linphone/oRTP/include/ortp/port.h
index 395523486e76f2d3790b7bb0786f42dc2242a21e..5d2a2d3f33d2c55f95fbd800c8e3c126a2f6f2da 100644
--- a/linphone/oRTP/include/ortp/port.h
+++ b/linphone/oRTP/include/ortp/port.h
@@ -75,8 +75,18 @@ typedef pthread_cond_t ortp_cond_t;
 #pragma warning(disable : 1469)		// "cc" clobber ignored
 #endif
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 int __ortp_thread_join(ortp_thread_t thread, void **ptr);
 int __ortp_thread_create(pthread_t *thread, pthread_attr_t *attr, void * (*routine)(void*), void *arg);
+
+#ifdef __cplusplus
+}
+#endif
+
 #define ortp_thread_create	__ortp_thread_create
 #define ortp_thread_join	__ortp_thread_join
 #define ortp_thread_exit	pthread_exit
diff --git a/linphone/oRTP/src/rtpsession.c b/linphone/oRTP/src/rtpsession.c
index b1926558bc840881ddc4ebe5d2fbc90f1b9530eb..b656d7e97a41f3988794309f583e2f51a809b753 100644
--- a/linphone/oRTP/src/rtpsession.c
+++ b/linphone/oRTP/src/rtpsession.c
@@ -213,6 +213,12 @@ mblk_t *rtp_getq_permissive(queue_t *q,uint32_t timestamp, int *rejected)
 void
 rtp_session_init (RtpSession * session, int mode)
 {
+	if (session == NULL) 
+	{
+	    ortp_debug("rtp_session_init: Invalid paramter (session=NULL)");
+	    return;
+	}
+	
 	JBParameters jbp;
 	memset (session, 0, sizeof (RtpSession));
 	session->mode = (RtpSessionMode) mode;
@@ -293,7 +299,12 @@ rtp_session_new (int mode)
 {
 	RtpSession *session;
 	session = (RtpSession *) ortp_malloc (sizeof (RtpSession));
-	rtp_session_init (session, mode);
+	if (session == NULL)
+	{
+	    ortp_error("rtp_session_new: Memory allocation failed");
+	    return NULL;
+	}
+      rtp_session_init (session, mode);
 	return session;
 }