mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 08:53:02 +01:00
fixed potential segfault
This commit is contained in:
parent
db309936ab
commit
094311785e
22
src/prompt.c
22
src/prompt.c
@ -331,18 +331,24 @@ void cmd_mynick(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
|
|
||||||
void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv)
|
void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *status, *status_text, *msg;
|
|
||||||
|
|
||||||
/* check arguments */
|
|
||||||
if (argv[2] && argv[2][0] != '\"') {
|
|
||||||
wprintw(self->window, "Messages must be enclosed in quotes.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (argc != 1 && argc != 2) {
|
if (argc != 1 && argc != 2) {
|
||||||
wprintw(self->window, "Wrong number of arguments.\n");
|
wprintw(self->window, "Wrong number of arguments.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *status, *status_text;
|
||||||
|
char *msg = NULL;
|
||||||
|
|
||||||
|
/* check arguments */
|
||||||
|
if (argc == 2) {
|
||||||
|
msg = argv[2];
|
||||||
|
if (msg[0] != '\"') {
|
||||||
|
wprintw(self->window, "Messages must be enclosed in quotes.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status = argv[1];
|
status = argv[1];
|
||||||
|
|
||||||
TOX_USERSTATUS status_kind;
|
TOX_USERSTATUS status_kind;
|
||||||
@ -364,8 +370,6 @@ void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
wprintw(self->window, "Status set to: %s\n", status_text);
|
wprintw(self->window, "Status set to: %s\n", status_text);
|
||||||
tox_set_userstatus(m, status_kind);
|
tox_set_userstatus(m, status_kind);
|
||||||
|
|
||||||
msg = argv[2];
|
|
||||||
|
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
msg[strlen(++msg)-1] = L'\0'; /* remove opening and closing quotes */
|
msg[strlen(++msg)-1] = L'\0'; /* remove opening and closing quotes */
|
||||||
tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user