POV-Ray : Newsgroups : povray.programming : Memory leak in pvbmp.c (POV-Ray windows version) Server Time
28 Jul 2024 14:28:52 EDT (-0400)
  Memory leak in pvbmp.c (POV-Ray windows version) (Message 1 to 4 of 4)  
From: Vahur Krouverk
Subject: Memory leak in pvbmp.c (POV-Ray windows version)
Date: 5 Mar 2001 12:52:03
Message: <3AA3D257.E2D0E519@aetec.ee>
Hello!

(Don't know, if this is already reported. If there were search engine
for news server... [hint, hint])
I found a memory leak in pvbmp.c. It seems to be present in most recent
version of official POV-Ray (v. 3.1g) and if v. 3.5 is based on same
Windows code, then it will be relevant to new version as well (or may-be
it is already corrected?)
Memory leak is in pvbmp.c file, line 744, where buffer is allocated for
filling bitmap file with line info, containing in the beginning BMP
magic bytes, but this buffer is never released. 
====================8<===================
      magic = POV_MALLOC(((*width*24+31)/32)*4, "BMP magic"); 
<---allocation
      memset(magic, 0, ((*width*24+31)/32)*4);
      magic[0] = MAGIC1;
      magic[1] = MAGIC2;
      magic[2] = MAGIC3;
      for (i=0; i<*height; i++)
        fwrite(magic, ((*width*24+31)/32)*4, 1, f);
        <---no freeing!
      break;
====================8<===================
Additionally, this code could be more effective, if instead of
calculating same expression for buffer size 3 times it is calculated
once and held in temporary variable. Moreover, for() loop is
unneccessary, instead fwrite could be used with count parameter (2nd
parameter) equal to *height.


Post a reply to this message

From: Pabs
Subject: Re: Memory leak in pvbmp.c (POV-Ray windows version)
Date: 5 Mar 2001 20:46:45
Message: <3aa44185$1@news.povray.org>
Vahur Krouverk wrote:

> Memory leak is in pvbmp.c file, line 744, where buffer is allocated for
> filling bitmap file with line info, containing in the beginning BMP
> magic bytes, but this buffer is never released.
> ====================8<===================
>       magic = POV_MALLOC(((*width*24+31)/32)*4, "BMP magic");
> <---allocation

AFAIK all mem allocated by POV_MALLOC is automatically freed.
But I am probably wrong.
--
Bye,
Pabs


Post a reply to this message

From: Mark Wagner
Subject: Re: Memory leak in pvbmp.c (POV-Ray windows version)
Date: 5 Mar 2001 23:46:27
Message: <3aa46ba3@news.povray.org>
Vahur Krouverk wrote in message <3AA3D257.E2D0E519@aetec.ee>...
>Hello!
>I found a memory leak in pvbmp.c. It seems to be present in most recent
>version of official POV-Ray (v. 3.1g) and if v. 3.5 is based on same
>Windows code, then it will be relevant to new version as well (or may-be
>it is already corrected?)
>Memory leak is in pvbmp.c file, line 744, where buffer is allocated for
>filling bitmap file with line info, containing in the beginning BMP
>magic bytes, but this buffer is never released.


I found this one a while back, but I don't remember if I reported it or not.

--
Mark


Post a reply to this message

From: Vahur Krouverk
Subject: Re: Memory leak in pvbmp.c (POV-Ray windows version)
Date: 6 Mar 2001 02:53:24
Message: <3AA49794.EE1A823F@aetec.ee>
Vahur Krouverk wrote:
> 
> Additionally, this code could be more effective, if instead of
> calculating same expression for buffer size 3 times it is calculated

Ouch, this should be:
.. for buffer size 2 + *height times it is calculated

> Moreover, for() loop is
> unneccessary, instead fwrite could be used with count parameter (2nd
> parameter) equal to *height.

And this is complete nonsense. Disregard this part of my message.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.