[Asterisk-code-review] stream: ast stream clone() cannot copy the opaque user data. (asterisk[master])

Joshua Colp asteriskteam at digium.com
Mon May 8 17:25:22 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/5593 )

Change subject: stream: ast_stream_clone() cannot copy the opaque user data.
......................................................................


stream: ast_stream_clone() cannot copy the opaque user data.

ast_stream_clone() cannot copy the opaque user data stored on a stream.
We don't know how to clone the data so it isn't copied into the clone.

Change-Id: Ia51321bf38ecbfdcc53787ca77ea5fd2cabdf367
---
M include/asterisk/stream.h
M main/stream.c
2 files changed, 8 insertions(+), 1 deletion(-)

Approvals:
  Mark Michelson: Looks good to me, approved
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit



diff --git a/include/asterisk/stream.h b/include/asterisk/stream.h
index 1bb34b7..821ecec 100644
--- a/include/asterisk/stream.h
+++ b/include/asterisk/stream.h
@@ -126,7 +126,7 @@
  * \retval NULL failure
  *
  * \note Opaque data pointers set with ast_stream_set_data() are not part
- * of the deep clone.  The pointers are simply copied.
+ * of the deep clone.  We have no way to clone the data.
  *
  * \since 15
  */
diff --git a/main/stream.c b/main/stream.c
index 0f23933..804a0b8 100644
--- a/main/stream.c
+++ b/main/stream.c
@@ -99,6 +99,7 @@
 {
 	struct ast_stream *new_stream;
 	size_t stream_size;
+	int idx;
 
 	if (!stream) {
 		return NULL;
@@ -115,6 +116,12 @@
 		ao2_ref(new_stream->formats, +1);
 	}
 
+	/* We cannot clone the opaque data because we don't know how. */
+	for (idx = 0; idx < AST_STREAM_DATA_SLOT_MAX; ++idx) {
+		new_stream->data[idx] = NULL;
+		new_stream->data_free_fn[idx] = NULL;
+	}
+
 	return new_stream;
 }
 

-- 
To view, visit https://gerrit.asterisk.org/5593
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia51321bf38ecbfdcc53787ca77ea5fd2cabdf367
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list