Closed Bug 211010 Opened 22 years ago Closed 22 years ago

Memory leak of 576 bytes from 3 blocks allocated in PR_Malloc

Categories

(Core :: Graphics: ImageLib, defect, P1)

x86
Windows 2000
defect

Tracking

()

VERIFIED FIXED
mozilla1.5alpha

People

(Reporter: stephend, Assigned: Biesinger)

References

()

Details

(Keywords: memory-leak)

Attachments

(1 file)

Trunk build, Windows 2000. Just doing - -url http://www.3drealms.com/max/walkthrough/p3c4.html under Purify yields: [W] MLK: Memory leak of 576 bytes from 3 blocks allocated in PR_Malloc Distribution of leaked blocks 576 bytes from 3 blocks of 192 bytes (first block: 0x0c6e3140) Allocation location malloc [dbgheap.c:129] PR_Malloc [prmem.c:474] gif_write(gif_struct *,BYTE const*,UINT) [GIF2.cpp:955] { PRUint8 *map = gs->local_colormap; if (!map) { => map = gs->local_colormap = (PRUint8*)PR_MALLOC(3 * gs->local_colormap_size); if (!map) { gs->state = gif_oom; break; nsGIFDecoder2::ProcessData(BYTE *,UINT,UINT *) [nsGIFDecoder2.cpp:195] // In the new decoder, we should always be able to process more data since // we don't wait to decode each frame in an animation now. if (gif_write_ready(mGIFStruct)) { => PRStatus result = gif_write(mGIFStruct, data, count); if (result != PR_SUCCESS) return NS_ERROR_FAILURE; } ReadDataOut [nsGIFDecoder2.cpp:137] PRUint32 *writeCount) { nsGIFDecoder2 *decoder = NS_STATIC_CAST(nsGIFDecoder2*, closure); => nsresult rv = decoder->ProcessData((unsigned char*)fromRawSegment, count, writeCount); if (NS_FAILED(rv)) { *writeCount = 0; return rv; nsInputStreamTee::WriteSegmentFun(nsIInputStream *,void *,char const*,UINT,UINT,UINT *) [nsInputStreamTee.cpp:105] { nsInputStreamTee *tee = NS_REINTERPRET_CAST(nsInputStreamTee *, closure); => nsresult rv = tee->mWriter(in, tee->mClosure, fromSegment, offset, count, writeCount); if (NS_FAILED(rv) || (*writeCount == 0)) { NS_ASSERTION((NS_FAILED(rv) ? (*writeCount == 0) : PR_TRUE), "writer returned an error with non-zero writeCount"); nsPipeInputStream::ReadSegments((*)(nsIInputStream *,void *,char const*,UINT,UINT,UINT *),void *,UINT,UINT *) [nsPipe3.cpp:731] while (segmentLen) { writeCount = 0; => rv = writer(this, closure, segment, *readCount, segmentLen, &writeCount); if (NS_FAILED(rv) || (writeCount == 0)) { count = 0; nsInputStreamTee::ReadSegments((*)(nsIInputStream *,void *,char const*,UINT,UINT,UINT *),void *,UINT,UINT *) [nsInputStreamTee.cpp:159] mWriter = writer; mClosure = closure; => return mSource->ReadSegments(WriteSegmentFun, this, count, bytesRead); } NS_IMETHODIMP nsGIFDecoder2::WriteFrom(nsIInputStream *,UINT,UINT *) [nsGIFDecoder2.cpp:215] /* unsigned long writeFrom (in nsIInputStream inStr, in unsigned long count); */ NS_IMETHODIMP nsGIFDecoder2::WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval) { => return inStr->ReadSegments(ReadDataOut, this, count, _retval); } imgRequest::OnDataAvailable(nsIRequest *,nsISupports *,nsIInputStream *,UINT,UINT) [imgRequest.cpp:797] } PRUint32 wrote; => nsresult rv = mDecoder->WriteFrom(inStr, count, &wrote); if (NS_FAILED(rv)) { PR_LOG(gImgLog, PR_LOG_WARNING,
Attached patch patchSplinter Review
for some reason, someone was just assinging nsnull to local_colormap, without freeing it. this patch changes it so that it does get freed. stephend confirmed that this fixes the leak.
Summary: Memory leak of 576 bytes from 3 blocks allocated in PR_Malloc → Memory leak of 576 bytes from 3 blocks allocated in PR_Malloc
Comment on attachment 126689 [details] [diff] [review] patch this is a very short patch to just fix a leak in the gif decoder, introduced in 2001 by the checkin for bug 73978.
Attachment #126689 - Flags: review?(pavlov)
Attachment #126689 - Flags: review?(pavlov) → review+
Attachment #126689 - Flags: superreview?(tor)
Attachment #126689 - Flags: superreview?(tor) → superreview+
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → mozilla1.5alpha
Checking in nsGIFDecoder2.cpp; /cvsroot/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp,v <-- nsGIFDecoder2.cpp new revision: 1.53; previous revision: 1.52 done
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
This was fixed - I tested the patch. Verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: