aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-11-16 23:40:35 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-11-16 23:51:26 -0500
commit68786449232dc6a9c989e8c9030078bac8c9f3f7 (patch)
treedebe991c1210485aad6395426829a7c64f9dc6b2
parent86901b1b7dd164e85246c7083a75de7904edcb7f (diff)
fix reading of string from file
Reading the string from the trace file did not zero out the end of the string. This caused funny characters to appear at the end of the version listing. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-read.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/trace-read.c b/trace-read.c
index e2c614a..f7fe6af 100644
--- a/trace-read.c
+++ b/trace-read.c
@@ -117,15 +117,17 @@ static char *read_string(void)
117 die("lseek"); 117 die("lseek");
118 118
119 if (str) { 119 if (str) {
120 size += i; 120 size += i + 1;
121 str = realloc(str, size); 121 str = realloc(str, size);
122 if (!str) 122 if (!str)
123 die("malloc of size %d", size); 123 die("malloc of size %d", size);
124 memcpy(str + (size - i), buf, i); 124 memcpy(str + (size - i), buf, i);
125 str[size] = 0;
125 } else { 126 } else {
126 size = i; 127 size = i + 1;
127 str = malloc_or_die(i); 128 str = malloc_or_die(i);
128 memcpy(str, buf, i); 129 memcpy(str, buf, i);
130 str[i] = 0;
129 } 131 }
130 132
131 return str; 133 return str;