Commit 913fcf1a authored by Mario Trangoni's avatar Mario Trangoni Committed by Mike Gabriel

Fix some memory leaks.

parent c58cbc26
...@@ -121,9 +121,15 @@ int main (int argc, char *argv[]) ...@@ -121,9 +121,15 @@ int main (int argc, char *argv[])
{ {
char* fname = malloc(strlen(directory)+strlen(filename)+1); char* fname = malloc(strlen(directory)+strlen(filename)+1);
if (fname == NULL)
{
printf("malloc failed\n");
exit(1);
}
strcpy(fname,directory); strcat(fname,filename); strcpy(fname,directory); strcat(fname,filename);
f = fopen(fname,"w"); f = fopen(fname,"w");
if (f == NULL) if (f == NULL)
free(fname);
exit(1); exit(1);
} }
......
...@@ -980,9 +980,10 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, ...@@ -980,9 +980,10 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
{ {
prmsg (1,"GetMyAddr: malloc failed\n"); prmsg (1,"GetMyAddr: malloc failed\n");
return -1; return -1;
} } else {
memcpy(*addrp, ciptr->addr, ciptr->addrlen); memcpy(*addrp, ciptr->addr, ciptr->addrlen);
free(addrp);
}
return 0; return 0;
} }
#endif #endif
...@@ -1003,7 +1004,7 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, ...@@ -1003,7 +1004,7 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
return -1; return -1;
} }
memcpy(*addrp, ciptr->peeraddr, ciptr->peeraddrlen); memcpy(*addrp, ciptr->peeraddr, ciptr->peeraddrlen);
free(addrp);
return 0; return 0;
} }
......
...@@ -2454,7 +2454,6 @@ SocketUNIXConnectPost: ...@@ -2454,7 +2454,6 @@ SocketUNIXConnectPost:
ciptr->peeraddrlen = namelen; ciptr->peeraddrlen = namelen;
memcpy (ciptr->addr, &sockname, ciptr->addrlen); memcpy (ciptr->addr, &sockname, ciptr->addrlen);
memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen); memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);
return 0; return 0;
} }
......
...@@ -656,6 +656,7 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx) ...@@ -656,6 +656,7 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
if (!others) if (!others)
return BadAlloc; return BadAlloc;
if (!pWin->optional->inputMasks && !MakeInputMasks(pWin)) if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
free(others);
return BadAlloc; return BadAlloc;
bzero((char *)&others->mask[0], sizeof(Mask) * EMASKSIZE); bzero((char *)&others->mask[0], sizeof(Mask) * EMASKSIZE);
others->mask[mskidx] = mask; others->mask[mskidx] = mask;
......
...@@ -371,6 +371,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, ...@@ -371,6 +371,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
if (!pShare) if (!pShare)
{ {
FreeCursorBits(bits); FreeCursorBits(bits);
free(pCurs);
return BadAlloc; return BadAlloc;
} }
pShare->font = sourcefont; pShare->font = sourcefont;
......
...@@ -629,10 +629,12 @@ int what; ...@@ -629,10 +629,12 @@ int what;
screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0, screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0,
(XID *)NULL, &status); (XID *)NULL, &status);
if (!screenContext[i]) if (!screenContext[i])
free(prect);
return; return;
numGCs++; numGCs++;
if (!AddResource(FakeClientID(0), ResType, if (!AddResource(FakeClientID(0), ResType,
(void *)screenContext[i])) (void *)screenContext[i]))
free(prect);
return; return;
} }
pGC = screenContext[i]; pGC = screenContext[i];
......
...@@ -995,6 +995,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) ...@@ -995,6 +995,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
{ {
listsBase = (GlyphListPtr) malloc (nlist * sizeof (GlyphListRec)); listsBase = (GlyphListPtr) malloc (nlist * sizeof (GlyphListRec));
if (!listsBase) if (!listsBase)
free(glyphsBase);
return BadAlloc; return BadAlloc;
} }
......
...@@ -283,6 +283,7 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -283,6 +283,7 @@ char *PngCompressData(XImage *image, int *compressed_size)
bitsPerPixel); bitsPerPixel);
#endif #endif
free(image_index);
return NULL; return NULL;
} }
...@@ -315,6 +316,7 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -315,6 +316,7 @@ char *PngCompressData(XImage *image, int *compressed_size)
fprintf(stderr, "******PngCompressData: PANIC! Failed creating the png_create_write_struct.\n"); fprintf(stderr, "******PngCompressData: PANIC! Failed creating the png_create_write_struct.\n");
#endif #endif
free(image_index);
return NULL; return NULL;
} }
...@@ -327,7 +329,7 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -327,7 +329,7 @@ char *PngCompressData(XImage *image, int *compressed_size)
#endif #endif
png_destroy_write_struct(&png_ptr, NULL); png_destroy_write_struct(&png_ptr, NULL);
free(image_index);
return NULL; return NULL;
} }
...@@ -339,6 +341,7 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -339,6 +341,7 @@ char *PngCompressData(XImage *image, int *compressed_size)
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
free(image_index);
return NULL; return NULL;
} }
...@@ -360,6 +363,7 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -360,6 +363,7 @@ char *PngCompressData(XImage *image, int *compressed_size)
PNG_DEST_SIZE(w, h)); PNG_DEST_SIZE(w, h));
#endif #endif
free(image_index);
return NULL; return NULL;
} }
...@@ -374,7 +378,6 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -374,7 +378,6 @@ char *PngCompressData(XImage *image, int *compressed_size)
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
free(pngCompBuf); free(pngCompBuf);
return NULL; return NULL;
} }
...@@ -470,7 +473,7 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -470,7 +473,7 @@ char *PngCompressData(XImage *image, int *compressed_size)
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
free(pngCompBuf); free(pngCompBuf);
free(image_index);
return NULL; return NULL;
} }
...@@ -484,7 +487,7 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -484,7 +487,7 @@ char *PngCompressData(XImage *image, int *compressed_size)
fprintf(stderr, "******PngCompressData: PANIC! Cannot allocate [%d] bytes.\n", fprintf(stderr, "******PngCompressData: PANIC! Cannot allocate [%d] bytes.\n",
(int) (w * sizeof(CARD8))); (int) (w * sizeof(CARD8)));
#endif #endif
free(image_index);
return NULL; return NULL;
} }
...@@ -516,7 +519,7 @@ char *PngCompressData(XImage *image, int *compressed_size) ...@@ -516,7 +519,7 @@ char *PngCompressData(XImage *image, int *compressed_size)
#endif #endif
free(pngCompBuf); free(pngCompBuf);
free(image_index);
return NULL; return NULL;
} }
......
...@@ -766,10 +766,12 @@ int what; ...@@ -766,10 +766,12 @@ int what;
screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0, screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0,
(XID *)NULL, &status); (XID *)NULL, &status);
if (!screenContext[i]) if (!screenContext[i])
free(prect);
return; return;
numGCs++; numGCs++;
if (!AddResource(FakeClientID(0), ResType, if (!AddResource(FakeClientID(0), ResType,
(void *)screenContext[i])) (void *)screenContext[i]))
free(prect);
return; return;
} }
pGC = screenContext[i]; pGC = screenContext[i];
......
...@@ -158,6 +158,8 @@ miZeroLine(pDraw, pGC, mode, npt, pptInit) ...@@ -158,6 +158,8 @@ miZeroLine(pDraw, pGC, mode, npt, pptInit)
pspanInit = (DDXPointPtr)malloc(list_len * sizeof(DDXPointRec)); pspanInit = (DDXPointPtr)malloc(list_len * sizeof(DDXPointRec));
pwidthInit = (int *)malloc(list_len * sizeof(int)); pwidthInit = (int *)malloc(list_len * sizeof(int));
if (!pspanInit || !pwidthInit) if (!pspanInit || !pwidthInit)
free(pspanInit);
free(pwidthInit);
return; return;
Nspans = 0; Nspans = 0;
......
...@@ -1346,6 +1346,8 @@ ProcRenderCompositeGlyphs (ClientPtr client) ...@@ -1346,6 +1346,8 @@ ProcRenderCompositeGlyphs (ClientPtr client)
{ {
listsBase = (GlyphListPtr) malloc (nlist * sizeof (GlyphListRec)); listsBase = (GlyphListPtr) malloc (nlist * sizeof (GlyphListRec));
if (!listsBase) if (!listsBase)
free(glyphsBase);
free(listsBase);
return BadAlloc; return BadAlloc;
} }
buffer = (CARD8 *) (stuff + 1); buffer = (CARD8 *) (stuff + 1);
...@@ -2918,9 +2920,7 @@ PanoramiXRenderFillRectangles (ClientPtr client) ...@@ -2918,9 +2920,7 @@ PanoramiXRenderFillRectangles (ClientPtr client)
result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client); result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client);
if(result != Success) break; if(result != Success) break;
} }
free(extra);
} }
return result; return result;
} }
...@@ -2979,10 +2979,9 @@ PanoramiXRenderTrapezoids(ClientPtr client) ...@@ -2979,10 +2979,9 @@ PanoramiXRenderTrapezoids(ClientPtr client)
if(result != Success) break; if(result != Success) break;
} }
free(extra);
} }
free(extra);
return result; return result;
} }
...@@ -3038,9 +3037,8 @@ PanoramiXRenderTriangles(ClientPtr client) ...@@ -3038,9 +3037,8 @@ PanoramiXRenderTriangles(ClientPtr client)
if(result != Success) break; if(result != Success) break;
} }
free(extra);
} }
free(extra);
return result; return result;
} }
...@@ -3092,9 +3090,8 @@ PanoramiXRenderTriStrip(ClientPtr client) ...@@ -3092,9 +3090,8 @@ PanoramiXRenderTriStrip(ClientPtr client)
if(result != Success) break; if(result != Success) break;
} }
free(extra);
} }
free(extra);
return result; return result;
} }
...@@ -3146,9 +3143,8 @@ PanoramiXRenderTriFan(ClientPtr client) ...@@ -3146,9 +3143,8 @@ PanoramiXRenderTriFan(ClientPtr client)
if(result != Success) break; if(result != Success) break;
} }
free(extra);
} }
free(extra);
return result; return result;
} }
...@@ -3276,9 +3272,8 @@ PanoramiXRenderAddTraps (ClientPtr client) ...@@ -3276,9 +3272,8 @@ PanoramiXRenderAddTraps (ClientPtr client)
result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client); result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
if(result != Success) break; if(result != Success) break;
} }
free(extra);
} }
free(extra);
return result; return result;
} }
......
...@@ -1038,6 +1038,7 @@ int UnsetEnv(const char *name) ...@@ -1038,6 +1038,7 @@ int UnsetEnv(const char *name)
} }
result = 0; result = 0;
delete[] varName;
#else #else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment