Ticket #5305: programs_mythtranscode-uninit-defects.patch

File programs_mythtranscode-uninit-defects.patch, 3.5 KB (added by Erik Hovland <erik@…>, 13 years ago)
  • programs/mythtranscode/mpeg2fix.cpp

    Make sure variables are initialized.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     programs/mythtranscode/mpeg2fix.cpp       |   15 ++++++++++-----
     programs/mythtranscode/mpeg2fix.h         |   20 +++++++++++++-------
     programs/mythtranscode/replex/multiplex.c |    2 +-
     3 files changed, 24 insertions(+), 13 deletions(-)
    
    diff --git a/programs/mythtranscode/mpeg2fix.cpp b/programs/mythtranscode/mpeg2fix.cpp
    index 28605b5..a506135 100644
    a b MPEG2fixup::MPEG2fixup(const char *inf, const char *outf, 
    214214
    215215    infile = inf;
    216216    rx.outfile = outf;
    217     rx.done = 0;
     217    rx.done = false;
    218218    format = fmt;
    219219    no_repeat = norp;
    220220    fix_PTS = fixPTS;
    int fill_buffers(void *r, int finish) 
    448448}
    449449
    450450MPEG2replex::MPEG2replex()
     451    : done(false), otype(-1)
     452    , ext_count(0), mplex(NULL)
    451453{
    452454    memset(&vrbuf, 0, sizeof(ringbuffer));
    453455    memset(&index_vrbuf, 0, sizeof(ringbuffer));
    454     memset(&extrbuf, 0, sizeof(ringbuffer) * N_AUDIO);
    455     memset(&index_extrbuf, 0, sizeof(ringbuffer) * N_AUDIO);
    456     ext_count = 0;
     456    memset(extrbuf, 0, sizeof(ringbuffer) * N_AUDIO);
     457    memset(index_extrbuf, 0, sizeof(ringbuffer) * N_AUDIO);
     458    memset(exttype, 0, sizeof(int) * N_AUDIO);
     459    memset(exttypcnt, 0, sizeof(int) * N_AUDIO);
     460    memset(extframe, 0, sizeof(audio_frame_t) * N_AUDIO);
     461    memset(&seq_head, 0, sizeof(seq_head));
    457462}
    458463
    459464MPEG2replex::~MPEG2replex()
    int MPEG2fixup::Start() 
    23782383            break;
    23792384    }
    23802385
    2381     rx.done = 1;
     2386    rx.done = true;
    23822387    pthread_mutex_lock( &rx.mutex );
    23832388    pthread_cond_signal(&rx.cond);
    23842389    pthread_mutex_unlock( &rx.mutex );
  • programs/mythtranscode/mpeg2fix.h

    diff --git a/programs/mythtranscode/mpeg2fix.h b/programs/mythtranscode/mpeg2fix.h
    index 8fadcf8..f976334 100644
    a b class MPEG2frame 
    4242{
    4343  public:
    4444    MPEG2frame(int size)
     45        : isSequence(false), isGop(false)
     46        , framePos(NULL),    gopPos(NULL)
    4547    {
    46         pkt.data = (uint8_t *)malloc(size);
    47         pkt_memsize = size;
     48        av_new_packet(&pkt, size);
     49        pkt.priv = NULL;
     50        memset(pkt.data, 0, sizeof(uint8_t) * pkt.size);
     51        memset(&mpeg2_seq, 0, sizeof(mpeg2_seq));
     52        memset(&mpeg2_gop, 0, sizeof(mpeg2_gop));
     53        memset(&mpeg2_pic, 0, sizeof(mpeg2_pic));
    4854    }
     55
    4956    ~MPEG2frame()
    5057    {
    51         free(pkt.data);
     58        av_destruct_packet(&pkt);
    5259    }
    5360    void ensure_size(int size)
    5461    {
    55         if (pkt_memsize < size)
     62        if (pkt.size < size)
    5663        {
    5764            pkt.data = (uint8_t *)realloc(pkt.data, size);
    58             pkt_memsize = size;
     65            pkt.size = size;
    5966        }
    6067    }
    6168    void set_pkt(AVPacket *newpkt)
    class MPEG2frame 
    6875    }
    6976
    7077    AVPacket pkt;
    71     int pkt_memsize;
    7278    bool isSequence;
    7379    bool isGop;
    7480    uint8_t *framePos;
    class MPEG2replex 
    108114    ~MPEG2replex();
    109115    void Start();
    110116    int WaitBuffers();
    111     int done;
     117    bool done;
    112118    QString outfile;
    113119    int otype;
    114120    ringbuffer vrbuf;
  • programs/mythtranscode/replex/multiplex.c

    diff --git a/programs/mythtranscode/replex/multiplex.c b/programs/mythtranscode/replex/multiplex.c
    index c341e7f..48ebb3a 100644
    a b static int which_ext(extdata_t *ext, int *aok, int n) 
    3333        int i;
    3434        int started = 0;
    3535        int pos = -1;
    36         uint64_t tmppts;
     36        uint64_t tmppts = 0;
    3737        for(i=0; i < n; i++)
    3838                if(aok[i]){
    3939                        if(! started){