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;
}
Alan Wehmann
[email protected]
On Nov 7, 2015, at 9:23 AM, Gavin Smith <[email protected]> wrote:
On 7 November 2015 at 14:54, Alan Wehmann <[email protected]> wrote:
Here is the Diff output:
diff -u install-info.c install-info-fixed.c
--- install-info.c 2015-02-27 12:57:27.000000000 -0600
+++ install-info-fixed.c 2015-11-07 08:48:36.000000000 -0600
@@ -1445,6 +1445,8 @@
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;
What happens if you take the "line_out[offset_out+1] = '\0'" line out
but leave the realloc in? Does it work for the test file or does it
break again?