]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ctf: strdup() -> xstrdup()
authorNick Alcock <nick.alcock@oracle.com>
Tue, 7 Mar 2017 23:27:12 +0000 (23:27 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 26 May 2017 00:06:08 +0000 (01:06 +0100)
Several unadorned strdup()s have crept into dwarf2ctf: all of them
should be xstrdup(), since none are handling malloc failure themselves.

Orabug: 25815306
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: tomas.jedlicka@oracle.com
scripts/dwarf2ctf/dwarf2ctf.c

index 9ce11ea2518ac51869781f144667d88caabbf9cc..2332501c317a6597f52c26d9ba0c480c4beefcd8 100644 (file)
@@ -1103,7 +1103,7 @@ static void init_dedup_blacklist(const char *dedup_blacklist_file)
                        line[len-1] = '\0';
 
 
-               g_hash_table_insert(dedup_blacklist, strdup(line), NULL);
+               g_hash_table_insert(dedup_blacklist, xstrdup(line), NULL);
        }
 
        if (ferror(f)) {
@@ -1999,8 +1999,8 @@ static void detect_duplicates_will_rescan(Dwarf_Die *die, const char *id,
                fprintf(stderr, "Out of memory allocating id_file\n");
                exit (1);
        }
-       id_file->file_name = strdup(state->file_name);
-       id_file->id = strdup(id);
+       id_file->file_name = xstrdup(state->file_name);
+       id_file->id = xstrdup(id);
        id_file->dieoff = dwarf_dieoffset(die);
        state->named_structs = g_slist_prepend(state->named_structs, id_file);
 }
@@ -4059,7 +4059,7 @@ static char *rel_abs_file_name(const char *file_name, const char *relative_to)
 
        abspath = realpath(file_name, NULL);
        if (abspath == NULL)
-               abspath = strdup(file_name);
+               abspath = xstrdup(file_name);
 
        if ((dir > -1) && (fchdir(dir) < 0)) {
                fprintf(stderr, "Cannot return to original directory "