Ticket #5238: libs_libmythfreemheg-uninit-defects.patch

File libs_libmythfreemheg-uninit-defects.patch, 11.5 KB (added by Erik Hovland <erik@…>, 16 years ago)

make sure that all variables are initialized when they need to be

  • libs/libmythfreemheg/BaseClasses.h

    Make sure all variables are initialized.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmythfreemheg/BaseClasses.h   |    4 ++--
     libs/libmythfreemheg/Bitmap.cpp      |    2 ++
     libs/libmythfreemheg/Groups.cpp      |    1 +
     libs/libmythfreemheg/Groups.h        |    2 +-
     libs/libmythfreemheg/Ingredients.cpp |    4 ++++
     libs/libmythfreemheg/Ingredients.h   |    3 ++-
     libs/libmythfreemheg/Link.cpp        |    1 +
     libs/libmythfreemheg/Stream.cpp      |    2 ++
     libs/libmythfreemheg/Text.cpp        |   18 ++++++++++--------
     libs/libmythfreemheg/Text.h          |    2 +-
     libs/libmythfreemheg/Variables.h     |    6 +++---
     libs/libmythfreemheg/Visible.cpp     |   10 ++++++++++
     12 files changed, 39 insertions(+), 16 deletions(-)
    
    diff --git a/libs/libmythfreemheg/BaseClasses.h b/libs/libmythfreemheg/BaseClasses.h
    index 635fca5..84c7f2b 100644
    a b protected: 
    192192class MHGenericBoolean: public MHGenericBase
    193193{
    194194public:
    195     MHGenericBoolean() {}
     195    MHGenericBoolean() : m_fDirect(false) {}
    196196    void Initialise(MHParseNode *p, MHEngine *engine);
    197197    void PrintMe(FILE *fd, int nTabs) const;
    198198    bool GetValue(MHEngine *engine) const; // Return the value, looking up any indirect ref.
    protected: 
    203203class MHGenericInteger: public MHGenericBase
    204204{
    205205public:
    206     MHGenericInteger() {}
     206    MHGenericInteger() : m_nDirect(-1) {}
    207207    void Initialise(MHParseNode *p, MHEngine *engine);
    208208    void PrintMe(FILE *fd, int nTabs) const;
    209209    int GetValue(MHEngine *engine) const; // Return the value, looking up any indirect ref.
  • libs/libmythfreemheg/Bitmap.cpp

    diff --git a/libs/libmythfreemheg/Bitmap.cpp b/libs/libmythfreemheg/Bitmap.cpp
    index aa94f69..14bb103 100644
    a b MHBitmap::MHBitmap() 
    4141{
    4242    m_fTiling = false;
    4343    m_nOrigTransparency = 0;
     44    m_nTransparency = 0;
    4445    m_nXDecodeOffset = 0;
    4546    m_nYDecodeOffset = 0;
    4647    m_pContent = NULL;
    MHBitmap::MHBitmap(const MHBitmap &ref): MHVisible(ref) 
    5051{
    5152    m_fTiling = ref.m_fTiling;
    5253    m_nOrigTransparency = ref.m_nOrigTransparency;
     54    m_nTransparency = 0;
    5355    m_nXDecodeOffset = 0;
    5456    m_nYDecodeOffset = 0;
    5557    m_pContent = NULL;
  • libs/libmythfreemheg/Groups.cpp

    diff --git a/libs/libmythfreemheg/Groups.cpp b/libs/libmythfreemheg/Groups.cpp
    index 2240366..7c3290d 100644
    a b  
    4040MHGroup::MHGroup()
    4141{
    4242    m_nOrigGCPriority = 127; // Default.
     43    m_fIsApp = false;
    4344    m_nLastId = 0;
    4445}
    4546
  • libs/libmythfreemheg/Groups.h

    diff --git a/libs/libmythfreemheg/Groups.h b/libs/libmythfreemheg/Groups.h
    index 324880b..be80db3 100644
    a b public: 
    157157class MHSendEvent: public MHElemAction
    158158{
    159159public:
    160     MHSendEvent(): MHElemAction(":SendEvent") {}
     160    MHSendEvent(): MHElemAction(":SendEvent"), m_EventType(EventIsAvailable) {}
    161161    virtual void Initialise(MHParseNode *p, MHEngine *engine);
    162162    virtual void Perform(MHEngine *engine);
    163163    virtual void PrintArgs(FILE *fd, int nTabs) const;
  • libs/libmythfreemheg/Ingredients.cpp

    diff --git a/libs/libmythfreemheg/Ingredients.cpp b/libs/libmythfreemheg/Ingredients.cpp
    index 6694e13..8798163 100644
    a b MHIngredient::MHIngredient() 
    3636    m_fShared = false;
    3737    m_nOrigContentSize = 0;
    3838    m_nOrigCCPrio = 127; // Default.
     39    m_nContentSize = 0;
     40    m_nCCPrio = 0;
    3941    m_ContentType = IN_NoContent;
    4042}
    4143
    MHIngredient::MHIngredient(const MHIngredient &ref): MHRoot(ref) 
    5153    m_nOrigContentSize = ref.m_nOrigContentSize;
    5254    m_nOrigCCPrio = ref.m_nOrigCCPrio;
    5355    m_fShared = ref.m_fShared;
     56    m_nContentSize = ref.m_nContentSize;
     57    m_nCCPrio = ref.m_nCCPrio;
    5458}
    5559
    5660
  • libs/libmythfreemheg/Ingredients.h

    diff --git a/libs/libmythfreemheg/Ingredients.h b/libs/libmythfreemheg/Ingredients.h
    index 76630c2..fefd833 100644
    a b protected: 
    120120class MHSetData: public MHElemAction
    121121{
    122122public:
    123     MHSetData(): MHElemAction(":SetData") {}
     123    MHSetData(): MHElemAction(":SetData"), m_fIsIncluded(false)
     124               ,m_fSizePresent(false), m_fCCPriorityPresent(false) {}
    124125    virtual void Initialise(MHParseNode *p, MHEngine *engine);
    125126    virtual void Perform(MHEngine *engine);
    126127    virtual void PrintArgs(FILE *fd, int nTabs) const;
  • libs/libmythfreemheg/Link.cpp

    diff --git a/libs/libmythfreemheg/Link.cpp b/libs/libmythfreemheg/Link.cpp
    index 30d0878..f889af7 100644
    a b  
    3232MHLink::MHLink()
    3333{
    3434    m_EventData.m_Type = MHUnion::U_None;
     35    m_nEventType = EventIsAvailable;
    3536}
    3637
    3738void MHLink::Initialise(MHParseNode *p, MHEngine *engine)
  • libs/libmythfreemheg/Stream.cpp

    diff --git a/libs/libmythfreemheg/Stream.cpp b/libs/libmythfreemheg/Stream.cpp
    index 9dda175..a25bee7 100644
    a b MHRoot *MHStream::FindByObjectNo(int n) 
    145145
    146146MHAudio::MHAudio()
    147147{
     148    m_nComponentTag = 0;
    148149    m_nOriginalVol = 0;
    149150    m_fStreamPlaying = false;
    150151}
    void MHAudio::StopPlaying(MHEngine *engine) 
    223224
    224225MHVideo::MHVideo()
    225226{
     227    m_nComponentTag = 0;
    226228    m_Termination = VI_Disappear;
    227229    m_nXDecodeOffset = 0;
    228230    m_nYDecodeOffset = 0;
  • libs/libmythfreemheg/Text.cpp

    diff --git a/libs/libmythfreemheg/Text.cpp b/libs/libmythfreemheg/Text.cpp
    index 4b48b4b..84a09d5 100644
    a b MHText::MHText() 
    3838    m_StartCorner = UpperLeft;
    3939    m_fTextWrap = false;
    4040    m_pDisplay = NULL;
     41    m_fNeedsRedraw = false;
    4142}
    4243
    4344MHText::MHText(const MHText &ref): MHVisible(ref) // Copy constructor for cloning.
    MHText::MHText(const MHText &ref): MHVisible(ref) // Copy constructor for clonin 
    5354    m_StartCorner = ref.m_StartCorner;
    5455    m_fTextWrap = ref.m_fTextWrap;
    5556    m_pDisplay = NULL;
     57    m_fNeedsRedraw = ref.m_fNeedsRedraw;
    5658}
    5759
    5860MHText::~MHText()
    void MHText::Initialise(MHParseNode *p, MHEngine *engine) 
    9395    if (pTextWrap) m_fTextWrap = pTextWrap->GetArgN(0)->GetBoolValue();
    9496
    9597    m_pDisplay = engine->GetContext()->CreateText();
    96     m_NeedsRedraw = true;
     98    m_fNeedsRedraw = true;
    9799}
    98100
    99101static const char *rchJustification[] =
    void MHText::Preparation(MHEngine *engine) 
    175177    MHVisible::Preparation(engine);
    176178
    177179    m_pDisplay->SetSize(m_nBoxWidth, m_nBoxHeight);
    178     m_NeedsRedraw = true;
     180    m_fNeedsRedraw = true;
    179181}
    180182
    181183// Content preparation.  If it's included we can set up the content.
    void MHText::ContentArrived(const unsigned char *data, int length, MHEngine *eng 
    193195    CreateContent(data, length, engine);
    194196    // Now signal that the content is available.
    195197    engine->EventTriggered(this, EventContentAvailable);
    196     m_NeedsRedraw = true;
     198    m_fNeedsRedraw = true;
    197199}
    198200
    199201//
    void MHText::CreateContent(const unsigned char *p, int s, MHEngine *engine) 
    201203{
    202204    m_Content.Copy(MHOctetString((const char *)p, s));
    203205    engine->Redraw(GetVisibleArea()); // Have to redraw if the content has changed.
    204     m_NeedsRedraw = true;
     206    m_fNeedsRedraw = true;
    205207//  fprintf(fd, "Text content is now "); m_Content.PrintMe(0); fprintf(fd, "\n");
    206208}
    207209
    208210void MHText::SetTextColour(const MHColour &colour, MHEngine *engine)
    209211{
    210212    m_textColour.Copy(colour);
    211     m_NeedsRedraw = true;
     213    m_fNeedsRedraw = true;
    212214    engine->Redraw(GetVisibleArea());
    213215}
    214216
    void MHText::SetBackgroundColour(const MHColour &colour, MHEngine *engine) 
    223225void MHText::SetFontAttributes(const MHOctetString &fontAttrs, MHEngine *engine)
    224226{
    225227    m_fontAttrs.Copy(fontAttrs);
    226     m_NeedsRedraw = true;
     228    m_fNeedsRedraw = true;
    227229    engine->Redraw(GetVisibleArea());
    228230}
    229231
    void MHText::Display(MHEngine *engine) 
    516518{
    517519    if (! m_fRunning || ! m_pDisplay || m_nBoxWidth == 0 || m_nBoxHeight == 0) return; // Can't draw zero sized boxes.
    518520    // We only need to recreate the display if something has changed.
    519     if ( m_NeedsRedraw)
     521    if ( m_fNeedsRedraw)
    520522    {
    521523        Redraw();
    522         m_NeedsRedraw = false;
     524        m_fNeedsRedraw = false;
    523525    }
    524526    // Draw the background first, then the text.
    525527    engine->GetContext()->DrawRect(m_nPosX, m_nPosY, m_nBoxWidth, m_nBoxHeight, GetColour(m_bgColour));
  • libs/libmythfreemheg/Text.h

    diff --git a/libs/libmythfreemheg/Text.h b/libs/libmythfreemheg/Text.h
    index caaa820..b1c353c 100644
    a b protected: 
    8484    MHOctetString   m_Content; // The content as an octet string
    8585
    8686    MHTextDisplay   *m_pDisplay; // Pointer to the display object.
    87     bool            m_NeedsRedraw;
     87    bool            m_fNeedsRedraw;
    8888
    8989    // Create the Unicode content from the character input.
    9090    void CreateContent(const unsigned char *p, int s, MHEngine *engine);
  • libs/libmythfreemheg/Variables.h

    diff --git a/libs/libmythfreemheg/Variables.h b/libs/libmythfreemheg/Variables.h
    index d6bf71c..3071cd2 100644
    a b public: 
    4141class MHBooleanVar : public MHVariable 
    4242{
    4343public:
    44     MHBooleanVar() {}
     44    MHBooleanVar(): m_fOriginalValue(false), m_fValue(false) {}
    4545    virtual const char *ClassName() { return "BooleanVariable"; }
    4646    virtual void Initialise(MHParseNode *p, MHEngine *engine);
    4747    virtual void PrintMe(FILE *fd, int nTabs) const;
    protected: 
    6262class MHIntegerVar : public MHVariable 
    6363{
    6464public:
    65     MHIntegerVar() {}
     65    MHIntegerVar(): m_nOriginalValue(0), m_nValue(0) {}
    6666    virtual const char *ClassName() { return "IntegerVariable"; }
    6767    virtual void Initialise(MHParseNode *p, MHEngine *engine);
    6868    virtual void PrintMe(FILE *fd, int nTabs) const;
    protected: 
    156156class MHTestVariable: public MHElemAction
    157157{
    158158public:
    159     MHTestVariable(): MHElemAction(":TestVariable") {}
     159    MHTestVariable(): MHElemAction(":TestVariable"), m_nOperator(0) {}
    160160    virtual void Initialise(MHParseNode *p, MHEngine *engine);
    161161    virtual void Perform(MHEngine *engine);
    162162protected:
  • libs/libmythfreemheg/Visible.cpp

    diff --git a/libs/libmythfreemheg/Visible.cpp b/libs/libmythfreemheg/Visible.cpp
    index ab8031e..bcae2e2 100644
    a b MHVisible::MHVisible() 
    3535{
    3636    m_nOriginalBoxWidth = m_nOriginalBoxHeight = -1; // Should always be specified.
    3737    m_nOriginalPosX = m_nOriginalPosY = 0; // Default values.
     38    m_nBoxWidth = m_nBoxHeight = 0;
     39    m_nPosX = m_nPosY = 0;
    3840}
    3941
    4042// Copy constructor for cloning
    MHVisible::MHVisible(const MHVisible &ref): MHPresentable(ref) 
    4446    m_nOriginalBoxHeight = ref.m_nOriginalBoxHeight;
    4547    m_nOriginalPosX = ref.m_nOriginalPosX;
    4648    m_nOriginalPosY = ref.m_nOriginalPosY;
     49    m_nBoxWidth = ref.m_nBoxWidth;
     50    m_nBoxHeight = ref.m_nBoxHeight;
     51    m_nPosX = ref.m_nPosX;
     52    m_nPosY = ref.m_nPosY;
    4753    m_OriginalPaletteRef.Copy(ref.m_OriginalPaletteRef);
    4854}
    4955
    MHLineArt::MHLineArt() 
    205211    m_fBorderedBBox = true;
    206212    m_nOriginalLineWidth = 1;
    207213    m_OriginalLineStyle = LineStyleSolid;
     214    m_nLineWidth = 0;
     215    m_LineStyle = 0;
    208216    // Colour defaults to empty.
    209217}
    210218
    MHLineArt::MHLineArt(const MHLineArt &ref): MHVisible(ref) 
    216224    m_OriginalLineStyle = ref.m_OriginalLineStyle;
    217225    m_OrigLineColour = ref.m_OrigLineColour;
    218226    m_OrigFillColour = ref.m_OrigFillColour;
     227    m_nLineWidth = ref.m_nLineWidth;
     228    m_LineStyle = ref.m_LineStyle;
    219229}
    220230
    221231void MHLineArt::Initialise(MHParseNode *p, MHEngine *engine)