dbTalk Databases Forums  

[BUGS] 7.3.4: memory leak in fe-exec.c:279 (realloc)

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] 7.3.4: memory leak in fe-exec.c:279 (realloc) in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Max Kellermann
 
Posts: n/a

Default [BUGS] 7.3.4: memory leak in fe-exec.c:279 (realloc) - 10-02-2003 , 09:12 AM






Hi,

I have found a memory leak in PostgreSQL 7.3.4,
src/interfaces/libpq/fe-exec.c line 279:

buffer = realloc(buffer, buflen);
if (buffer == NULL)
return NULL;

The realloc manpage says:

"If realloc() fails the original block is left untouched - it is
not freed or moved."

i.e. "buffer" is not freed if there is not enough memory for
realloc. The code should be like this:

temp_buffer = realloc(buffer, buflen);
if (temp_buffer == NULL) {
free(buffer);
return NULL;
}
buffer = temp_buffer;

Regards,
Max Kellermann

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] 7.3.4: memory leak in fe-exec.c:279 (realloc) - 10-02-2003 , 10:02 AM






Max Kellermann <max (AT) linuxtag (DOT) org> writes:
Quote:
I have found a memory leak in PostgreSQL 7.3.4,
src/interfaces/libpq/fe-exec.c line 279:
This appears to have been dealt with already (although realistically,
it would be an extremely brain-dead realloc that could ever fail here,
since the block is being shrunk not grown).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.