aboutsummaryrefslogtreecommitdiff
path: root/gprof
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-08-03 08:23:51 +0930
committerAlan Modra <amodra@gmail.com>2023-08-03 21:19:54 +0930
commit23f6f86ca03e87883150d21a6ac3c00590ea450a (patch)
tree43a8b4587ca4ce6ff3d0db179003dac90d509c20 /gprof
parent137f6bc0dabe209c1617fb396eb590e7b7ee8faa (diff)
downloadbinutils-23f6f86ca03e87883150d21a6ac3c00590ea450a.zip
binutils-23f6f86ca03e87883150d21a6ac3c00590ea450a.tar.gz
binutils-23f6f86ca03e87883150d21a6ac3c00590ea450a.tar.bz2
gprof: sprintf sanitizer null destination pointer
* basic_blocks.c (annotate_with_count): Use output of sprintf rather than strlen.
Diffstat (limited to 'gprof')
-rw-r--r--gprof/basic_blocks.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/gprof/basic_blocks.c b/gprof/basic_blocks.c
index 6073f55..7fbba8c 100644
--- a/gprof/basic_blocks.c
+++ b/gprof/basic_blocks.c
@@ -360,8 +360,7 @@ annotate_with_count (char *buf, unsigned int width, int line_num, void *arg)
execution count (if bb_annotate_all_lines is set). */
if (b->is_func)
{
- sprintf (p, "%lu", b->ncalls);
- p += strlen (p);
+ p += sprintf (p, "%lu", b->ncalls);
last_count = b->ncalls;
last_print = last_count;
ncalls = b->ncalls;
@@ -370,8 +369,7 @@ annotate_with_count (char *buf, unsigned int width, int line_num, void *arg)
else if (bb_annotate_all_lines
&& b->bb_addr[0] && b->bb_addr[0] > b->addr)
{
- sprintf (p, "%lu", last_count);
- p += strlen (p);
+ p += sprintf (p, "%lu", last_count);
last_print = last_count;
ncalls = last_count;
ncalls_set = 1;
@@ -396,8 +394,7 @@ annotate_with_count (char *buf, unsigned int width, int line_num, void *arg)
if (p > tmpbuf)
*p++ = ',';
- sprintf (p, "%lu", last_count);
- p += strlen (p);
+ p += sprintf (p, "%lu", last_count);
last_print = last_count;
}
@@ -410,8 +407,7 @@ annotate_with_count (char *buf, unsigned int width, int line_num, void *arg)
if (bb_annotate_all_lines && p == tmpbuf)
{
- sprintf (p, "%lu", last_count);
- p += strlen (p);
+ p += sprintf (p, "%lu", last_count);
ncalls = last_count;
ncalls_set = 1;
}