Date: Thu, 12 Jul 2018 18:48:54 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336226 - head/contrib/elftoolchain/elfcopy Message-ID: <201807121848.w6CImsL5013190@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Thu Jul 12 18:48:53 2018 New Revision: 336226 URL: https://svnweb.freebsd.org/changeset/base/336226 Log: Pass the right sizes to malloc() and realloc(). Reported by: scan-build, via Mark Millard MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D16180 Modified: head/contrib/elftoolchain/elfcopy/sections.c Modified: head/contrib/elftoolchain/elfcopy/sections.c ============================================================================== --- head/contrib/elftoolchain/elfcopy/sections.c Thu Jul 12 18:44:00 2018 (r336225) +++ head/contrib/elftoolchain/elfcopy/sections.c Thu Jul 12 18:48:53 2018 (r336226) @@ -716,13 +716,13 @@ filter_reloc(struct elfcopy *ecp, struct section *s) #define COPYREL(REL, SZ) do { \ if (nrels == 0) { \ if ((REL##SZ = malloc(cap * \ - sizeof(Elf##SZ##_Rel))) == NULL) \ + sizeof(*REL##SZ))) == NULL) \ err(EXIT_FAILURE, "malloc failed"); \ } \ if (nrels >= cap) { \ cap *= 2; \ if ((REL##SZ = realloc(REL##SZ, cap * \ - sizeof(Elf##SZ##_Rel))) == NULL) \ + sizeof(*REL##SZ))) == NULL) \ err(EXIT_FAILURE, "realloc failed"); \ } \ REL##SZ[nrels].r_offset = REL.r_offset; \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807121848.w6CImsL5013190>