[MPlayer-cvslog] r38379 - trunk/libmpdemux/demux_viv.c
reimar
subversion at mplayerhq.hu
Fri Aug 26 14:52:50 EEST 2022
Author: reimar
Date: Fri Aug 26 14:52:50 2022
New Revision: 38379
Log:
demux_viv.c: code review fixes.
use calloc, ensure string termination, fix obfuscated
string constant, remove superfluous return statements,
remove unnecessary null check for demuxer->priv.
Modified:
trunk/libmpdemux/demux_viv.c
Modified: trunk/libmpdemux/demux_viv.c
==============================================================================
--- trunk/libmpdemux/demux_viv.c Fri Aug 26 14:44:47 2022 (r38378)
+++ trunk/libmpdemux/demux_viv.c Fri Aug 26 14:52:50 2022 (r38379)
@@ -104,22 +104,16 @@ static void vivo_parse_text_header(demux
char *opt, *param;
int parser_in_audio_block = 0;
- if (!demux->priv)
- {
- priv = malloc(sizeof(vivo_priv_t));
- memset(priv, 0, sizeof(vivo_priv_t));
- demux->priv = priv;
- priv->supported = 0;
- }
-
- buf = malloc(header_len);
- opt = malloc(header_len);
- param = malloc(header_len);
+ // extra character for 0 termination.
+ // header_len is max 16 bit.
+ buf = calloc(1, header_len + 1);
+ opt = calloc(1, header_len + 1);
+ param = calloc(1, header_len + 1);
stream_read(demux->stream, buf, header_len);
i=0;
while(i<header_len && buf[i]==0x0D && buf[i+1]==0x0A) i+=2; // skip empty lines
- token = strtok(buf, (char *)&("\x0d\x0a"));
+ token = strtok(buf, "\r\n");
while (token && (header_len>2))
{
header_len -= strlen(token)+2;
@@ -260,16 +254,14 @@ static int vivo_check_file(demuxer_t* de
mp_msg(MSGT_DEMUX,MSGL_V,"header block 1 size: %d\n",len);
//stream_skip(demuxer->stream,len);
- priv=malloc(sizeof(vivo_priv_t));
- memset(priv,0,sizeof(vivo_priv_t));
- demuxer->priv=priv;
+ demuxer->priv=priv=calloc(1, sizeof(vivo_priv_t));
#if 0
vivo_parse_text_header(demuxer, len);
if (priv->supported == 0)
return 0;
#else
- /* this is enought for check (for now) */
+ /* this is enough for check (for now) */
stream_read(demuxer->stream,buf,len);
buf[len]=0;
// printf("VIVO header: '%s'\n",buf);
@@ -656,10 +648,11 @@ static demuxer_t* demux_open_vivo(demuxe
}
/* AUDIO init */
-if (demuxer->audio->id >= -1){
+if (demuxer->audio->id < -1) goto nosound;
if(!ds_fill_buffer(demuxer->audio)){
mp_msg(MSGT_DEMUX,MSGL_ERR,"VIVO: " MSGTR_MissingAudioStream);
- } else
+ goto nosound;
+ }
{ sh_audio_t* sh=new_sh_audio(demuxer,1, NULL);
/* Select audio codec */
@@ -745,10 +738,8 @@ if (demuxer->audio->id >= -1){
/* insert as stream */
demuxer->audio->sh=sh;
demuxer->audio->id=1;
-nosound:
- return demuxer;
-}
}
+nosound:
return demuxer;
}
@@ -763,7 +754,6 @@ static void demux_close_vivo(demuxer_t *
free(priv->producer);
free(priv);
}
- return;
}
More information about the MPlayer-cvslog
mailing list