aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorHui Zhu <teawater@gmail.com>2011-12-10 09:41:19 +0000
committerHui Zhu <teawater@gmail.com>2011-12-10 09:41:19 +0000
commitdf5a4bd3a546613628d251202271ea2d10ba8608 (patch)
treeb040a0e649b4c1249fa6b21b9742ee58b4b582d2 /gdb
parent7181d6843d057546cf35eacb4c2f55e931698979 (diff)
downloadgdb-df5a4bd3a546613628d251202271ea2d10ba8608.zip
gdb-df5a4bd3a546613628d251202271ea2d10ba8608.tar.gz
gdb-df5a4bd3a546613628d251202271ea2d10ba8608.tar.bz2
2011-12-10 Hui Zhu <teawater@gmail.com>
* tracepoint.c (create_tsv_from_upload): Change sprintf to xstrprintf.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/tracepoint.c16
2 files changed, 16 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e29f557..704bbea 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2011-12-10 Hui Zhu <teawater@gmail.com>
+
+ * tracepoint.c (create_tsv_from_upload): Change sprintf to xstrprintf.
+
2011-12-09 Andrey Smirnov <andrew.smirnov@gmail.com>
* breakpoint.c (bp_loc_is_permanent): Rename `brk' to
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index e00538c..fa79d53 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -3482,31 +3482,39 @@ struct trace_state_variable *
create_tsv_from_upload (struct uploaded_tsv *utsv)
{
const char *namebase;
- char buf[20];
+ char *buf;
int try_num = 0;
struct trace_state_variable *tsv;
+ struct cleanup *old_chain;
if (utsv->name)
{
namebase = utsv->name;
- sprintf (buf, "%s", namebase);
+ buf = xstrprintf ("%s", namebase);
}
else
{
namebase = "__tsv";
- sprintf (buf, "%s_%d", namebase, try_num++);
+ buf = xstrprintf ("%s_%d", namebase, try_num++);
}
/* Fish for a name that is not in use. */
/* (should check against all internal vars?) */
while (find_trace_state_variable (buf))
- sprintf (buf, "%s_%d", namebase, try_num++);
+ {
+ xfree (buf);
+ buf = xstrprintf ("%s_%d", namebase, try_num++);
+ }
+
+ old_chain = make_cleanup (xfree, buf);
/* We have an available name, create the variable. */
tsv = create_trace_state_variable (buf);
tsv->initial_value = utsv->initial_value;
tsv->builtin = utsv->builtin;
+ do_cleanups (old_chain);
+
return tsv;
}