Re: [Powertop] [bugreport] crash on powertop --debug --html=file.html

Sergey Senozhatsky <sergey.senozhatsky at gmail.com> Sun, 01 Jul 2012 21:13:51 +0300
Newsgroups dev.linux.lists.powertop
Message-ID <20120701181351.GD4770@swordfish>
On (07/01/12 15:46), Jan-Simon Möller wrote:
> Am Mittwoch, 27. Juni 2012, 18:32:42 schrieb Sergey Senozhatsky:
> > 
> > Could you please run
> > 
> >  valgrind --tool=memcheck --leak-check=full --show-reachable=yes
> > --leak-resolution=high --track-origins=yes -v
> > --log-file=./powertop-memcheck powertop --debug --html=file.html
> > 
> > and provide powertop-memcheck file?
> > 
> > 
> > 	-ss
> 
> Attached.

Thanks, I'll take a look.

Meanwhile, could you please try the following patch?

---

 src/devlist.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/devlist.cpp b/src/devlist.cpp
index 93f2081..9f06b92 100644
--- a/src/devlist.cpp
+++ b/src/devlist.cpp
@@ -146,11 +146,12 @@ void collect_open_devices(void)
 				if (!dev)
 					continue;
 				dev->pid = strtoull(entry->d_name, NULL, 10);
-				strncpy(dev->device, link, 251);
+				strncpy(dev->device, link, 250);
+				dev->device[251] = 0x00;
 				sprintf(filename, "/proc/%s/comm", entry->d_name);
-				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 31);
+				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 30);
+				dev->comm[31] = 0x00;
 				target->push_back(dev);
-
 			}
 		}
 		closedir(dir2);