Authors: Mike McCormack <mikem@codeweavers.com>, Jeremy White <jwhite@codeweavers.com>

Fixed memory leaks.
This commit is contained in:
Alexandre Julliard 2002-06-13 23:54:55 +00:00
parent bf2c7efaa2
commit a5755b10a7
5 changed files with 37 additions and 21 deletions

View File

@ -885,6 +885,8 @@ HRESULT WINAPI IStream16_fnWrite(
* (we just migrate newsize bytes)
*/
LPBYTE curdata,data = HeapAlloc(GetProcessHeap(),0,newsize+BIGSIZE);
HRESULT r = E_FAIL;
cc = newsize;
blocknr = This->stde.pps_sb;
curdata = data;
@ -899,31 +901,35 @@ HRESULT WINAPI IStream16_fnWrite(
}
/* frees complete chain for this stream */
if (!STORAGE_set_big_chain(hf,This->stde.pps_sb,STORAGE_CHAINENTRY_FREE))
return E_FAIL;
goto err;
curdata = data;
blocknr = This->stde.pps_sb = STORAGE_get_free_small_blocknr(hf);
if (blocknr<0)
return E_FAIL;
goto err;
cc = newsize;
while (cc>0) {
if (!STORAGE_put_small_block(hf,blocknr,curdata))
return E_FAIL;
goto err;
cc -= SMALLSIZE;
if (cc<=0) {
if (!STORAGE_set_small_chain(hf,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return E_FAIL;
goto err;
break;
} else {
int newblocknr = STORAGE_get_free_small_blocknr(hf);
if (newblocknr<0)
return E_FAIL;
goto err;
if (!STORAGE_set_small_chain(hf,blocknr,newblocknr))
return E_FAIL;
goto err;
blocknr = newblocknr;
}
curdata += SMALLSIZE;
}
r = S_OK;
err:
HeapFree(GetProcessHeap(),0,data);
if(r != S_OK)
return r;
}
}
This->stde.pps_size = newsize;
@ -978,47 +984,51 @@ HRESULT WINAPI IStream16_fnWrite(
} else {
/* Migrate small blocks to big blocks */
LPBYTE curdata,data = HeapAlloc(GetProcessHeap(),0,oldsize+BIGSIZE);
HRESULT r = E_FAIL;
cc = oldsize;
blocknr = This->stde.pps_sb;
curdata = data;
/* slurp in */
while (cc>0) {
if (!STORAGE_get_small_block(hf,blocknr,curdata)) {
HeapFree(GetProcessHeap(),0,data);
return E_FAIL;
}
if (!STORAGE_get_small_block(hf,blocknr,curdata))
goto err2;
curdata += SMALLSIZE;
cc -= SMALLSIZE;
blocknr = STORAGE_get_next_small_blocknr(hf,blocknr);
}
/* free small block chain */
if (!STORAGE_set_small_chain(hf,This->stde.pps_sb,STORAGE_CHAINENTRY_FREE))
return E_FAIL;
goto err2;
curdata = data;
blocknr = This->stde.pps_sb = STORAGE_get_free_big_blocknr(hf);
if (blocknr<0)
return E_FAIL;
goto err2;
/* put the data into the big blocks */
cc = This->stde.pps_size;
while (cc>0) {
if (!STORAGE_put_big_block(hf,blocknr,curdata))
return E_FAIL;
goto err2;
cc -= BIGSIZE;
if (cc<=0) {
if (!STORAGE_set_big_chain(hf,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return E_FAIL;
goto err2;
break;
} else {
int newblocknr = STORAGE_get_free_big_blocknr(hf);
if (newblocknr<0)
return E_FAIL;
goto err2;
if (!STORAGE_set_big_chain(hf,blocknr,newblocknr))
return E_FAIL;
goto err2;
blocknr = newblocknr;
}
curdata += BIGSIZE;
}
r = S_OK;
err2:
HeapFree(GetProcessHeap(),0,data);
if(r != S_OK)
return r;
}
/* generate big blocks to fit the new data */
lastblocknr = blocknr;

View File

@ -115,9 +115,9 @@ inline static void queue_file_op( struct file_op_queue *queue, struct file_op *o
/* free all the file operations on a given queue */
static void free_file_op_queue( struct file_op_queue *queue )
{
struct file_op *op;
struct file_op *t, *op = queue->head;
for (op = queue->head; op; op = op->next)
while( op )
{
HeapFree( GetProcessHeap(), 0, op->src_root );
HeapFree( GetProcessHeap(), 0, op->src_path );
@ -126,6 +126,9 @@ static void free_file_op_queue( struct file_op_queue *queue )
HeapFree( GetProcessHeap(), 0, op->src_tag );
HeapFree( GetProcessHeap(), 0, op->dst_path );
if (op->dst_file != op->src_file) HeapFree( GetProcessHeap(), 0, op->dst_file );
t = op;
op = op->next;
HeapFree( GetProcessHeap(), 0, t );
}
}

View File

@ -711,6 +711,7 @@ DWORD WINAPI FormatMessage16(
b = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, b, sz);
}
for (x=b; *x; x++) ADD_TO_T(*x);
HeapFree(GetProcessHeap(), 0, b);
} else {
/* NULL args - copy formatstr
* (probably wrong)

View File

@ -1053,6 +1053,7 @@ static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt )
/* No window was found, so it's OK for us */
pt.x = x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2;
pt.y = y - (yspacing + GetSystemMetrics(SM_CYICON)) / 2;
HeapFree( GetProcessHeap(), 0, list );
return pt;
} while(x <= rectParent.right-xspacing);

View File

@ -1222,15 +1222,16 @@ static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
/* Create a region from the strokes */
hrgn=CreatePolyPolygonRgn(pPath->pPoints, pNumPointsInStroke,
numStrokes, nPolyFillMode);
/* Free memory for number-of-points-in-stroke array */
HeapFree( GetProcessHeap(), 0, pNumPointsInStroke );
if(hrgn==(HRGN)0)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
/* Free memory for number-of-points-in-stroke array */
HeapFree( GetProcessHeap(), 0, pNumPointsInStroke );
/* Success! */
*pHrgn=hrgn;
return TRUE;