[asterisk-commits] rtp engine: Skip useless self-assignment in ast rtp engine u... (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 2 07:52:29 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format.
......................................................................


rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format.

When running valgrind on Asterisk, it complained about:

    ==32423== Source and destination overlap in memcpy(0x85a920, 0x85a920, 304)
    ==32423==    at 0x4C2F71C: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/...)
    ==32423==    by 0x55BA91: ast_rtp_engine_unload_format (rtp_engine.c:2292)
    ==32423==    by 0x4EEFB7: ast_format_attr_unreg_interface (format.c:1437)

The code in question is a struct assignment, which may be performed by
memcpy as a compiler optimization. It is changed to only copy the struct
contents if source and destination are different.

ASTERISK-25219 #close

Change-Id: I6d3546c326b03378ca8e9b8cefd41c16e0088b9a
---
M main/rtp_engine.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved



diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index e09dcb8..2d61c89 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -1798,7 +1798,9 @@
 			rtp_engine_mime_type_cleanup(x);
 			continue;
 		}
-		ast_rtp_mime_types[y] = ast_rtp_mime_types[x];
+		if (x != y) {
+			ast_rtp_mime_types[y] = ast_rtp_mime_types[x];
+		}
 		y++;
 	}
 	mime_types_len = y;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6d3546c326b03378ca8e9b8cefd41c16e0088b9a
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Walter Doekes <walter+asterisk at wjd.nu>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list