Re: [dev] [vis] buffer_alloc issues

From: Marc André Tanner <mat_AT_brain-dump.org>
Date: Sun, 29 Mar 2015 21:05:26 +0200

On Wed, Mar 25, 2015 at 07:15:08PM +0000, noname_AT_inventati.org wrote:
> I'm not sure if vis is supported in suckless mailing list, but as it was
> discussed here previously, i'm writing here.
>
> There are two issues with buffer_alloc function(s).
>
> First function is located in buffer.c:
> http://repo.or.cz/w/vis.git/blob/HEAD:/buffer.c
>
> The problem is on line 15:
> http://repo.or.cz/w/vis.git/blob/HEAD:/buffer.c#l15
>
> If realloc fails, buf->data is set to NULL, but original buf->data is
> not freed, see realloc(3). The result of realloc should be stored in
> separate variable and buffer_free should be called to free buf->data and
> set size and len to 0 if realloc fails.

I agree, thanks for the report. Do you mind sending a patch?

In general all memory allocation should be checked, keeping the current
state is always preferable to crashing and losing unsaved changes.

> Another issue is that there is another buffer_alloc in text.c:
> http://repo.or.cz/w/vis.git/blob/HEAD:/text.c
>
> Maybe these functions and data structures should be renamed to avoid
> name conflict.

I'm not sure I agree, what alternative name do you suggest?

-- 
 Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0
Received on Sun Mar 29 2015 - 21:05:26 CEST

This archive was generated by hypermail 2.3.0 : Sun Mar 29 2015 - 21:12:13 CEST