All of lore.kernel.org
 help / color / mirror / Atom feed
* libipfwc memory leak?
@ 2002-09-23 14:39 Andriy T. Yanko
  2002-09-27 20:44 ` Anders Fugmann
  0 siblings, 1 reply; 3+ messages in thread
From: Andriy T. Yanko @ 2002-09-23 14:39 UTC (permalink / raw)
  To: netfilter

Hi people!

I know that this letter is not for this mailllist. But I'm tired to find mistake.

I just writen this smal code for example:

--- cut ---
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include "libipfwc/libipfwc.h"


int main( int argc, char **argv)
{
    pid_t pid;

    unsigned int num_chains; 
    unsigned int num_rules; 
    static struct ipfwc_fwchain *chains;
    struct ipfwc_fwrule *rules;

    pid=fork();
    if ( pid == -1 ) { printf("Can't fork!\n"); exit(0); }
    if ( pid != 0) exit(0);
    setsid();

    while(1)
    {
	chains=ipfwc_get_chainnames(&num_chains); 
	rules=ipfwc_get_rules(&num_rules,0); 
	sleep(1);
    }
    
    return 0;
}
--- end ---

When program is runnig I just type command "ps aux" 
and I saw that my program get more and more system memory.

Is this memory leak of libipfwc library?

In  libipfwc.c  function ipfwc_get_chainnames & ipfwc_get_rules use malloc() but not use free().
It's maybe ok for program ipchains but in my case is not gut.

How to fix it?

THANKS IN ADVANCE.


-- 
Andriy T. Yanko
wireless@wireless.org.ua

* Avoid The Gates of Hell use Linux


^ permalink raw reply	[flat|nested] 3+ messages in thread

* libipfwc memory leak?
@ 2002-09-24  6:11 Andriy T. Yanko
  0 siblings, 0 replies; 3+ messages in thread
From: Andriy T. Yanko @ 2002-09-24  6:11 UTC (permalink / raw)
  To: netfilter

Hi people!

I know that this letter is not for this mailllist. But I'm tired to find mistake.

I just writen this smal code for example:

--- cut ---
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include "libipfwc/libipfwc.h"


int main( int argc, char **argv)
{
    pid_t pid;

    unsigned int num_chains; 
    unsigned int num_rules; 
    static struct ipfwc_fwchain *chains;
    struct ipfwc_fwrule *rules;

    pid=fork();
    if ( pid == -1 ) { printf("Can't fork!\n"); exit(0); }
    if ( pid != 0) exit(0);
    setsid();

    while(1)
    {
	chains=ipfwc_get_chainnames(&num_chains); 
	rules=ipfwc_get_rules(&num_rules,0); 
	sleep(1);
    }
    
    return 0;
}
--- end ---

When program is runnig I just type command "ps aux" 
and I saw that my program get more and more system memory.

Is this memory leak of libipfwc library?

In  libipfwc.c  function ipfwc_get_chainnames & ipfwc_get_rules use malloc() but not use free().
It's maybe ok for program ipchains but in my case is not gut.

How to fix it?

THANKS IN ADVANCE.


-- 
Andriy T. Yanko
wireless@wireless.org.ua

* Avoid The Gates of Hell use Linux


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libipfwc memory leak?
  2002-09-23 14:39 libipfwc memory leak? Andriy T. Yanko
@ 2002-09-27 20:44 ` Anders Fugmann
  0 siblings, 0 replies; 3+ messages in thread
From: Anders Fugmann @ 2002-09-27 20:44 UTC (permalink / raw)
  To: Andriy T.Yanko; +Cc: netfilter

Andriy T.Yanko wrote:
> Hi people!
> 
> In  libipfwc.c  function ipfwc_get_chainnames & ipfwc_get_rules use malloc() but not use free().
> It's maybe ok for program ipchains but in my case is not gut.
> 
> How to fix it?
You have to free the structures yourself. If the functions themself 
freed the structures, they would not be able to return anything.
This is not an error in libipfwc.

Regards
Anders Fugmann



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-27 20:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-23 14:39 libipfwc memory leak? Andriy T. Yanko
2002-09-27 20:44 ` Anders Fugmann
  -- strict thread matches above, loose matches on Subject: below --
2002-09-24  6:11 Andriy T. Yanko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.