diff options
author | Walter Doekes <walter+asterisk@wjd.nu> | 2015-07-02 13:10:59 +0200 |
---|---|---|
committer | Walter Doekes <walter+asterisk@wjd.nu> | 2015-07-02 06:19:05 -0500 |
commit | 13a318bbb10df7b49bdc2a1e45b939f779aa63aa (patch) | |
tree | 8d6c65dcad1cc88650e5ad30a8478a1be8b47b28 /main/rtp_engine.c | |
parent | c12ace3ab31bd61606252f5a3721ce720d2ad209 (diff) |
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
Diffstat (limited to 'main/rtp_engine.c')
-rw-r--r-- | main/rtp_engine.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/main/rtp_engine.c b/main/rtp_engine.c index 88d2db3d0..6ae8faf9c 100644 --- a/main/rtp_engine.c +++ b/main/rtp_engine.c @@ -1798,7 +1798,9 @@ int ast_rtp_engine_unload_format(struct ast_format *format) 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; |