]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
elflint: process_file both prefix and suffix are NULL or both are non-NULL
authorMark Wielaard <mark@klomp.org>
Tue, 11 Feb 2025 13:46:44 +0000 (14:46 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 11 Feb 2025 13:46:44 +0000 (14:46 +0100)
Add an assert of this property to help static analyzers (or humans)
reading this code.

* src/elflint.c (process_file): Add assert.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/elflint.c

index cdc6108d928733fac9126d352ca80feea59a8505..a46682c757ea0e152801a73bfdedc273966dd4be 100644 (file)
@@ -252,6 +252,10 @@ process_file (int fd, Elf *elf, const char *prefix, const char *suffix,
        char new_suffix[(suffix == NULL ? 0 : strlen (suffix)) + 2];
        char *cp = new_prefix;
 
+       /* Either both prefix and suffix are NULL or both are non-NULL.  */
+       assert ((prefix == NULL && suffix == NULL)
+               || (prefix != NULL && suffix != NULL));
+
        /* Create the full name of the file.  */
        if (prefix != NULL)
          {