Skip to content

Commit

Permalink
Fix SIGABRT due to not guaranteed true assert()ion
Browse files Browse the repository at this point in the history
Starting program: /home/osboxes/Workspace/slack/slack++ derp
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
slack++: /home/osboxes/Workspace/slack/main.cpp:23: int main(int, char**): Assertion `token != nullptr' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff54178a0 in raise () from /usr/lib/libc.so.6
(gdb) bt
0  0x00007ffff54178a0 in raise () at /usr/lib/libc.so.6
1  0x00007ffff5418f09 in abort () at /usr/lib/libc.so.6
2  0x00007ffff54100dc in __assert_fail_base () at /usr/lib/libc.so.6
3  0x00007ffff5410153 in  () at /usr/lib/libc.so.6
4  0x0000555555585da8 in main(int, char**) (argc=2, argv=0x7fffffffea78)
    at /home/osboxes/Workspace/slack/main.cpp:23
  • Loading branch information
ctrlcctrlv committed Oct 20, 2017
1 parent 09a0786 commit 788948e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ int main(int argc, char* argv[]) {
if (!token) {
// fallback to default token name
token = std::getenv("SLACK_TOKEN");
if (!token && argc == 1) {
std::cerr << "No token specified. Check helper message (\"--help\")" << std::endl;;
exit(EXIT_FAILURE);
if (!token) {
if (argc == 1) {
std::cerr << "No token specified. Check helper message (\"--help\")" << std::endl;;
exit(EXIT_FAILURE);
} else if (argc > 1) {
std::cerr << "Neither specific token nor default token found. Check helper message (\"--help\")" << std::endl;;
exit(EXIT_FAILURE);
}
}
}

assert(token != nullptr);

SlackUI ui;
Expand Down

0 comments on commit 788948e

Please sign in to comment.