* Tidy string_ptr increment
@ 2023-03-24 10:35 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-03-24 10:35 UTC (permalink / raw)
To: binutils
I was going to make this
vars->string_ptr += strlen (vars->string_ptr) + 1;
but figured we ought to be able to trust sprintf return value
nowadays.
* peicode.h (pe_ILF_make_a_symbol): Use sprintf output to
increment string_ptr to end of new string.
diff --git a/bfd/peicode.h b/bfd/peicode.h
index f1f3ce81533..f16aeca7a1b 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -576,7 +576,7 @@ pe_ILF_make_a_symbol (pe_ILF_vars * vars,
esym = vars->esym_ptr;
/* Copy the symbol's name into the string table. */
- sprintf (vars->string_ptr, "%s%s", prefix, symbol_name);
+ int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name);
if (section == NULL)
section = bfd_und_section_ptr;
@@ -612,7 +612,7 @@ pe_ILF_make_a_symbol (pe_ILF_vars * vars,
vars->table_ptr ++;
vars->native_ptr ++;
vars->esym_ptr ++;
- vars->string_ptr += strlen (symbol_name) + strlen (prefix) + 1;
+ vars->string_ptr += len + 1;
BFD_ASSERT (vars->string_ptr < vars->end_string_ptr);
}
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-24 10:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 10:35 Tidy string_ptr increment Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).