[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6756] use a local variable
From: |
Gavin D. Smith |
Subject: |
[6756] use a local variable |
Date: |
Sat, 07 Nov 2015 11:01:05 +0000 |
Revision: 6756
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6756
Author: gavin
Date: 2015-11-07 11:01:04 +0000 (Sat, 07 Nov 2015)
Log Message:
-----------
use a local variable
Modified Paths:
--------------
trunk/ChangeLog
trunk/install-info/install-info.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-11-07 10:46:27 UTC (rev 6755)
+++ trunk/ChangeLog 2015-11-07 11:01:04 UTC (rev 6756)
@@ -1,5 +1,10 @@
2015-11-07 Gavin Smith <address@hidden>
+ * install-info/install-info.c (format_entry): Use a local
+ variable to avoid dereferences of output variable.
+
+2015-11-07 Gavin Smith <address@hidden>
+
Comments and formatting changes.
* install-info/install-info.c (parse_input): Combine a comment
with comment at start of function, and add more information.
Modified: trunk/install-info/install-info.c
===================================================================
--- trunk/install-info/install-info.c 2015-11-07 10:46:27 UTC (rev 6755)
+++ trunk/install-info/install-info.c 2015-11-07 11:01:04 UTC (rev 6756)
@@ -1386,9 +1386,9 @@
NAME is of the form "* TEXT (TEXT)[:TEXT].".
*/
static int
-format_entry (char *name, size_t name_len, char *desc, size_t desc_len,
- int calign, int align, size_t width,
- char **outstr, size_t *outstr_len)
+format_entry (char *name, size_t name_len, char *desc, size_t desc_len,
+ int calign, int align, size_t width,
+ char **outstr_out, size_t *outstr_len)
{
int i, j;
char c;
@@ -1396,15 +1396,17 @@
size_t offset_out = 0; /* Index in `line_out' for next char. */
static char *line_out = NULL;
static size_t allocated_out = 0;
+ char *outstr;
+
if (!desc || !name)
return 1;
- *outstr = malloc (width +
+ outstr = malloc (width +
(((desc_len + width) / (width - align)) * width) * 2
* sizeof (char));
- *outstr[0] = '\0';
+ outstr[0] = '\0';
- strncat (*outstr, name, name_len);
+ strncat (outstr, name, name_len);
column = name_len;
@@ -1413,12 +1415,12 @@
/* Name is too long to have description on the same line. */
if (desc_len > 1)
{
- strncat (*outstr, "\n", 1);
+ strncat (outstr, "\n", 1);
column = 0;
for (j = 0; j < calign - 1; j++)
{
column = adjust_column (column, ' ');
- strncat (*outstr, " ", 1);
+ strncat (outstr, " ", 1);
}
}
}
@@ -1428,7 +1430,7 @@
if (desc_len <= 2)
break;
column = adjust_column (column, ' ');
- strncat (*outstr, " ", 1);
+ strncat (outstr, " ", 1);
}
for (i = 0; i < desc_len; i++)
@@ -1445,7 +1447,7 @@
if (c == '\n')
{
line_out[offset_out++] = c;
- strncat (*outstr, line_out, offset_out);
+ strncat (outstr, line_out, offset_out); /************/
column = offset_out = 0;
continue;
}
@@ -1480,12 +1482,12 @@
/* Found a blank. Don't output the part after it. */
logical_end++;
- strncat (*outstr, line_out, logical_end);
- strncat (*outstr, "\n", 1);
+ strncat (outstr, line_out, logical_end);
+ strncat (outstr, "\n", 1);
for (j = 0; j < align - 1; j++)
{
column = adjust_column (column, ' ');
- strncat (*outstr, " ", 1);
+ strncat (outstr, " ", 1);
}
/* Move the remainder to the beginning of the next
@@ -1506,7 +1508,7 @@
}
line_out[offset_out++] = '\n';
- strncat (*outstr, line_out, offset_out);
+ strncat (outstr, line_out, offset_out);
column = offset_out = 0;
goto rescan;
}
@@ -1515,12 +1517,13 @@
}
if (desc_len <= 2)
- strncat (*outstr, "\n", 1);
+ strncat (outstr, "\n", 1);
if (offset_out)
- strncat (*outstr, line_out, offset_out);
+ strncat (outstr, line_out, offset_out);
- *outstr_len = strlen (*outstr);
+ *outstr_out = outstr;
+ *outstr_len = strlen (outstr);
return 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6756] use a local variable,
Gavin D. Smith <=