Wildfire: fix memory leak.
[citadel.git] / libcitadel / lib / wildfire.c
index babdd86f3d69a4f106afe88c670af78de2f80238..1958f5920202085358cf509045f8071452f067f4 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: wildfire.c 6962 2009-01-18 19:33:45Z dothebart $
- */
-
 /*@{*/
 
 #include "sysdep.h"
@@ -161,9 +157,13 @@ static int addr2lineBacktrace(StrBuf *Function,
        pche = strchr(pch, ':');
        FlushStrBuf(FileName);
        StrBufAppendBufPlain(FileName, pch, pche - pch, 0);
-       pche++;
-       *FunctionLine = atoi(pche);
-
+       if (pche != NULL)
+       {
+               pche++;
+               *FunctionLine = atoi(pche);
+       }
+       else 
+               *FunctionLine = 0;
        return 1;
 }
 
@@ -373,6 +373,8 @@ void WildFireSerializePayload(StrBuf *JsonBuffer, StrBuf *OutBuf, int *MsgCount,
        const char *Cat;
        StrBuf *Header;
 
+       if (OutBuf == NULL)
+               Header = NewStrBuf();
        if (*MsgCount == 0) {
                if (OutBuf != NULL) {
                        StrBufAppendBufPlain(OutBuf, 
@@ -392,7 +394,6 @@ void WildFireSerializePayload(StrBuf *JsonBuffer, StrBuf *OutBuf, int *MsgCount,
                                                     "http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1\r\n"), 0);
                }
                else {
-                       Header = NewStrBuf();
                        AddHdr("X-Wf-Protocol-1", 
                               "http://meta.wildfirehq.org/Protocol/JsonStream/0.2");
                        AddHdr("X-Wf-1-Plugin-1",