]> code.citadel.org Git - citadel.git/commitdiff
* be more paranoid and do memset 0 all our structs
authorWilfried Göesgens <willi@citadel.org>
Thu, 11 Jun 2009 14:49:54 +0000 (14:49 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 11 Jun 2009 14:49:54 +0000 (14:49 +0000)
webcit/subst.c

index 3d9fc53923d1287d66048f79be66581970e69ce1..2cb30437ac394e54c5a69cdd1f04152267f93895 100644 (file)
@@ -292,6 +292,7 @@ void RegisterNS(const char *NSName,
        HashHandler *NewHandler;
        
        NewHandler = (HashHandler*) malloc(sizeof(HashHandler));
+       memset(NewHandler, 0, sizeof(HashHandler));
        NewHandler->Filter.nMinArgs = nMinArgs;
        NewHandler->Filter.nMaxArgs = nMaxArgs;
        NewHandler->Filter.ContextType = ContextRequired;
@@ -311,6 +312,7 @@ void RegisterControlNS(const char *NSName,
        HashHandler *NewHandler;
        
        NewHandler = (HashHandler*) malloc(sizeof(HashHandler));
+       memset(NewHandler, 0, sizeof(HashHandler));
        NewHandler->Filter.nMinArgs = nMinArgs;
        NewHandler->Filter.nMaxArgs = nMaxArgs;
        NewHandler->Filter.ContextType = CTX_NONE;
@@ -1083,6 +1085,7 @@ void PutNewToken(WCTemplate *Template, WCTemplateToken *NewToken)
                if (Template->TokenSpace <= 0) {
                        Template->Tokens = (WCTemplateToken**)malloc(
                                sizeof(WCTemplateToken*) * 10);
+                       memset(Template->Tokens, 0, sizeof(WCTemplateToken*));
                        Template->TokenSpace = 10;
                }
                else {
@@ -1104,10 +1107,12 @@ TemplateParam *GetNextParameter(StrBuf *Buf, const char **pCh, const char *pe, W
 {
        const char *pch = *pCh;
        const char *pchs, *pche;
-       TemplateParam *Parm = (TemplateParam *) malloc(sizeof(TemplateParam));
+       TemplateParam *Parm;
        char quote = '\0';
        int ParamBrace = 0;
 
+       Parm = (TemplateParam *) malloc(sizeof(TemplateParam));
+       memset(Parm, 0, sizeof(TemplateParam));
        Parm->Type = TYPE_STR;
 
        /* Skip leading whitespaces */
@@ -1250,9 +1255,11 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
        void *vVar;
        const char *pch;
        TemplateParam *Param;
-       WCTemplateToken *NewToken = (WCTemplateToken*)malloc(sizeof(WCTemplateToken));
+       WCTemplateToken *NewToken;
        WCTemplputParams TP;
 
+       NewToken = (WCTemplateToken*)malloc(sizeof(WCTemplateToken));
+       memset(NewToken, 0, sizeof(WCTemplateToken));
        TP.Tokens = NewToken;
        NewToken->FileName = pTmpl->FileName; /* to print meaningfull log messages... */
        NewToken->Flags = 0;
@@ -1420,7 +1427,9 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
 void *prepare_template(StrBuf *filename, StrBuf *Key, HashList *PutThere)
 {
        WCTemplate *NewTemplate;
+
        NewTemplate = (WCTemplate *) malloc(sizeof(WCTemplate));
+       memset(NewTemplate, 0, sizeof(WCTemplate));
        NewTemplate->Data = NULL;
        NewTemplate->FileName = NewStrBufDup(filename);
        NewTemplate->nTokensUsed = 0;
@@ -1462,6 +1471,7 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere)
        }
 
        NewTemplate = (WCTemplate *) malloc(sizeof(WCTemplate));
+       memset(NewTemplate, 0, sizeof(WCTemplate));
        NewTemplate->Data = NewStrBufPlain(NULL, statbuf.st_size);
        NewTemplate->FileName = NewStrBufDup(filename);
        NewTemplate->nTokensUsed = 0;
@@ -1845,7 +1855,10 @@ void RegisterITERATOR(const char *Name, long len,
                      int XPectContextType, 
                      int Flags)
 {
-       HashIterator *It = (HashIterator*)malloc(sizeof(HashIterator));
+       HashIterator *It;
+
+       It = (HashIterator*)malloc(sizeof(HashIterator));
+       memset(It, 0, sizeof(HashIterator));
        It->StaticList = StaticList;
        It->AdditionalParams = AdditionalParams;
        It->GetHash = GetHash;
@@ -2087,7 +2100,10 @@ void RegisterConditional(const char *Name, long len,
                         WCConditionalFunc CondF, 
                         int ContextRequired)
 {
-       ConditionalStruct *Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct));
+       ConditionalStruct *Cond;
+
+       Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct));
+       memset(Cond, 0, sizeof(ConditionalStruct));
        Cond->PlainName = Name;
        Cond->Filter.nMaxArgs = nParams;
        Cond->Filter.nMinArgs = nParams;
@@ -2102,7 +2118,10 @@ void RegisterControlConditional(const char *Name, long len,
                                WCConditionalFunc CondF, 
                                int ControlContextRequired)
 {
-       ConditionalStruct *Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct));
+       ConditionalStruct *Cond;
+
+       Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct));
+       memset(Cond, 0, sizeof(ConditionalStruct));
        Cond->PlainName = Name;
        Cond->Filter.nMaxArgs = nParams;
        Cond->Filter.nMinArgs = nParams;
@@ -2174,6 +2193,7 @@ void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP)
 
        nTabs = ntabs = TP->Tokens->nParameters / 2;
        TabNames = (StrBuf **) malloc(ntabs * sizeof(StrBuf*));
+       memset(TabNames, 0, ntabs * sizeof(StrBuf*));
 
        for (i = 0; i < ntabs; i++) {
                if ((TP->Tokens->Params[i * 2]->Type == TYPE_STR) &&
@@ -2218,7 +2238,10 @@ void RegisterSortFunc(const char *name, long len,
                      CompareFunc GroupChange, 
                      long ContextType)
 {
-       SortStruct *NewSort = (SortStruct*) malloc(sizeof(SortStruct));
+       SortStruct *NewSort;
+
+       NewSort = (SortStruct*) malloc(sizeof(SortStruct));
+       memset(NewSort, 0, sizeof(SortStruct));
        NewSort->Name = NewStrBufPlain(name, len);
        if (prepend != NULL)
                NewSort->PrefPrepend = NewStrBufPlain(prepend, preplen);