[MPlayer-dev-eng] [PATCH] Remove needless memsets after calloc
Alexander Strasser
eclipse7 at gmx.net
Sat Jan 6 03:03:43 EET 2018
Hi Michael!
On 2018-01-01 13:39 -0500, Michael McConville wrote:
>
> Unless, I’m missing something obvious, this is pretty self-explanatory.
You are not missing anything AFAICT.
Seem to be oversights from SVN commit r18559 , but they may
be security relevant. I cannot say for sure, because I did
not fully analyze these code paths and all possible memset
implementations.
Either way I believe it's better to remove those memset calls.
Committed your patch.
>Calloc zeroes memory, so there’s no need to re-zero it, and modern compilers often miss this optimization.
>From a quick glance, those don't seem important for performance.
Thank you for your contribution!
Alexander
> Index: libmpdemux/muxer_avi.c
> ===================================================================
> --- libmpdemux/muxer_avi.c (revision 38012)
> +++ libmpdemux/muxer_avi.c (working copy)
> @@ -120,7 +120,6 @@
> si->idx=calloc(si->idxsize, sizeof(struct avi_odmlidx_entry));
> si->riffofssize=16;
> si->riffofs=calloc((si->riffofssize+1), sizeof(off_t));
> - memset(si->riffofs, 0, sizeof(off_t)*si->riffofssize);
>
> switch(type){
> case MUXER_TYPE_VIDEO:
> @@ -619,7 +618,6 @@
>
> si->superidxsize = si->superidxpos;
> si->superidx = calloc(si->superidxsize, sizeof(*si->superidx));
> - memset(si->superidx, 0, sizeof(*si->superidx) * si->superidxsize);
>
> idxpos = 0;
> for (j=0; j<si->superidxpos; j++) {
More information about the MPlayer-dev-eng
mailing list