Fixed CID 1299: the char* name was used in a call to strtoul on line 1220

before being NULL checked on line 1234. I moved the null check to be after name
is initialized and removed it from line 1234.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27428 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood
2008-09-12 04:28:09 +00:00
parent 9b54ac7464
commit d1363991a8
+3 -2
View File
@@ -1218,6 +1218,7 @@ dump_thread_info(int argc, char **argv)
for (; argi < argc; argi++) { for (; argi < argc; argi++) {
const char *name = argv[argi]; const char *name = argv[argi];
if (name != NULL) {
int32 id = strtoul(name, NULL, 0); int32 id = strtoul(name, NULL, 0);
if (IS_KERNEL_ADDRESS(id)) { if (IS_KERNEL_ADDRESS(id)) {
@@ -1232,8 +1233,7 @@ dump_thread_info(int argc, char **argv)
hash_open(sThreadHash, &i); hash_open(sThreadHash, &i);
struct thread *thread; struct thread *thread;
while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) { while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) {
if ((name != NULL && !strcmp(name, thread->name)) if (!strcmp(name, thread->name) || thread->id == id) {
|| thread->id == id) {
_dump_thread_info(thread, shortInfo); _dump_thread_info(thread, shortInfo);
found = true; found = true;
break; break;
@@ -1244,6 +1244,7 @@ dump_thread_info(int argc, char **argv)
if (!found) if (!found)
kprintf("thread \"%s\" (%ld) doesn't exist!\n", name, id); kprintf("thread \"%s\" (%ld) doesn't exist!\n", name, id);
} }
}
return 0; return 0;
} }