[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem using install-info with tar.info
From: |
Gavin Smith |
Subject: |
Re: problem using install-info with tar.info |
Date: |
Mon, 9 Nov 2015 16:52:06 +0000 |
On 7 November 2015 at 21:19, Alan Wehmann <address@hidden> wrote:
> If I have the following:
>
> if (c == '\n')
> {
> line_out[offset_out++] = c;
> line_out = (char *) realloc ((void *)line_out, allocated_out+1);
> /* line_out[offset_out+1] = '\0'; */
> strncat (*outstr, line_out, offset_out);
> column = offset_out = 0;
> continue;
> }
>
> then there is no Abort trap: 6 error and the dir file is written.
>
> I checked again that the error occurs if both my added lines are not there,
> and that it does not occur if both my added lines are present.
>
> The error also occurs with:
>
> if (c == '\n')
> {
> line_out[offset_out++] = c;
> /* line_out = (char *) realloc ((void *)line_out, allocated_out+1);
> */
> line_out[offset_out+1] = '\0';
> strncat (*outstr, line_out, offset_out);
> column = offset_out = 0;
> continue;
> }
>
If all it needs is one extra byte in the allocation, we could do:
Index: install-info.c
===================================================================
--- install-info.c (revision 6758)
+++ install-info.c (working copy)
@@ -1444,7 +1444,7 @@ format_entry (char *name, size_t name_len, char *d
if (offset_out + 1 >= allocated_out)
{
allocated_out = offset_out + 1;
- line_out = (char *) realloc ((void *)line_out, allocated_out);
+ line_out = (char *) realloc ((void *)line_out, allocated_out + 1);
}
if (c == '\n')
I'll commit that (along with a comment saying that it's for a problem
with strncat) if it works for you.