/* Extracted from chown.c/chgrp.c and librarified by Jim Meyering. */
+/* GCC 10 gives a false postive warning with -fanalyzer for this. */
+#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__
+# pragma GCC diagnostic ignored "-Wanalyzer-double-free"
+#endif
+
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
/* Written by Richard Stallman and David MacKenzie. */
+/* GCC 10 gives a false postive warning with -fanalyzer for this. */
+#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__
+# pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value"
+#endif
+
#include <config.h>
#include <getopt.h>
static char space_character = ' ';
/* Input buffer. */
+static char *real_ibuf;
+/* aligned offset into the above. */
static char *ibuf;
/* Output buffer. */
+static char *real_obuf;
+/* aligned offset into the above. */
static char *obuf;
/* Current index into 'obuf'. */
if (ibuf)
return;
- char *real_buf = malloc (input_blocksize + INPUT_BLOCK_SLOP);
- if (!real_buf)
+ real_ibuf = malloc (input_blocksize + INPUT_BLOCK_SLOP);
+ if (!real_ibuf)
{
uintmax_t ibs = input_blocksize;
char hbuf[LONGEST_HUMAN_READABLE + 1];
human_opts | human_base_1024, 1, 1));
}
- real_buf += SWAB_ALIGN_OFFSET; /* allow space for swab */
-
- ibuf = ptr_align (real_buf, page_size);
+ ibuf = ptr_align (real_ibuf + SWAB_ALIGN_OFFSET, page_size);
}
/* Ensure output buffer OBUF is allocated/initialized. */
if (conversions_mask & C_TWOBUFS)
{
/* Page-align the output buffer, too. */
- char *real_obuf = malloc (output_blocksize + OUTPUT_BLOCK_SLOP);
+ real_obuf = malloc (output_blocksize + OUTPUT_BLOCK_SLOP);
if (!real_obuf)
{
uintmax_t obs = output_blocksize;
static void
cleanup (void)
{
+#ifdef lint
+ free (real_ibuf);
+ free (real_obuf);
+ real_ibuf = NULL;
+ real_obuf = NULL;
+#endif
+
if (iclose (STDIN_FILENO) != 0)
die (EXIT_FAILURE, errno, _("closing input file %s"), quoteaf (input_file));
if (sq)
break;
- /* Store the ${VARNAME} value. Error checking omitted as
- the ${VARNAME} was already validated. */
+ /* Store the ${VARNAME} value. */
{
char *n = extract_varname (str);
+ assert (n); /* ${VARNAME} already validated. */
char *v = getenv (n);
if (v)
{
while (true)
{
/* A2. Compare. */
+ assert (str && p && p->str);
a = strcmp (str, p->str);
if (a == 0)
return p;
p->right = q;
/* A6. Adjust balance factors. */
- assert (!STREQ (str, s->str));
+ assert (str && s && s->str && !STREQ (str, s->str));
if (strcmp (str, s->str) < 0)
{
r = p = s->left;
while (p != q)
{
- assert (!STREQ (str, p->str));
+ assert (str && p && p->str && !STREQ (str, p->str));
if (strcmp (str, p->str) < 0)
{
p->balance = -1;
{
struct successor *p;
+/* GCC 10 gives a false postive warning with -fanalyzer for this,
+ and an assert did not suppress the warning
+ with the initial GCC 10 release. */
+#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wanalyzer-null-dereference"
if (!STREQ (j->str, k->str))
{
k->count++;
p->next = j->top;
j->top = p;
}
+# pragma GCC diagnostic pop
+#endif
}
static bool