[PATCH] Replace unchecked malloc with xmalloc
Nandakumar Edamana
nandakumar@nandakumar.co.in
Thu Apr 4 05:26:14 GMT 2024
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 066c99a4d4f..7a3d20f0af9 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -876,7 +876,7 @@ dlltmp (char **buf, const char *fmt)
{
if (!*buf)
{
- *buf = malloc (strlen (tmp_prefix) + 64);
+ *buf = xmalloc (strlen (tmp_prefix) + 64);
sprintf (*buf, fmt, tmp_prefix);
}
return *buf;
This is the first time I submit a patch to binutils. Please guide me if
I'm doing it wrong.
An automated script lists more occurrences of unchecked mallocs, and a
quick manual review points to potentially unsound code from a memory
safety perspective. But I'll wait until this patch gets reviewed.
Thank you,
--
Nandakumar Edamana
https://nandakumar.org/
More information about the Binutils
mailing list