poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/12] libpoke: Fix `muls` insn to use `pvm_alloc`


From: Mohammad-Reza Nabipoor
Subject: Re: [PATCH 03/12] libpoke: Fix `muls` insn to use `pvm_alloc`
Date: Sun, 30 May 2021 02:10:48 +0430

On Thu, May 27, 2021 at 01:49:30PM +0200, Jose E. Marchesi wrote:
> 
> > @@ -4213,14 +4213,13 @@ instruction muls ()
> >    code
> >      pvm_val str = JITTER_UNDER_TOP_STACK ();
> >      size_t i, num = PVM_VAL_ULONG (JITTER_TOP_STACK ());
> > -    char *res = xmalloc (strlen (PVM_VAL_STR (str)) * num + 1);
> > +    char *res = pvm_alloc (strlen (PVM_VAL_STR (str)) * num + 1);
> >  
> >      *res = '\0';
> >      for (i = 0; i < num; ++i)
> >        strcat (res, PVM_VAL_STR (str));
> >  
> > -    JITTER_PUSH_STACK (pvm_make_string (res));
> > -    free (res);
> > +    JITTER_PUSH_STACK (pvm_make_string_nodup (res));
> >    end
> >  end
> 
> So we were leaking memory there...
> 


No, just a redundant allocation (or, I'm unable to see the leak).


> OK for both master and maint/poke-1.


Pushed.
Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]