diff --git a/src/audio_call.c b/src/audio_call.c index f49544e..64692eb 100644 --- a/src/audio_call.c +++ b/src/audio_call.c @@ -70,6 +70,7 @@ static int set_call(Call* call, bool start) if ( start ) { call->ttas = true; + if (pthread_mutex_init(&call->mutex, NULL) != 0) return -1; } diff --git a/src/chat.c b/src/chat.c index f69a53a..255b6a5 100644 --- a/src/chat.c +++ b/src/chat.c @@ -1013,7 +1013,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m) self->x = x2; /* Truncate note if it doesn't fit in statusbar */ - uint16_t maxlen = x2 - getcurx(statusbar->topline) - (KEY_IDENT_DIGITS * 2) - 6; + uint16_t maxlen = x2 - getcurx(statusbar->topline) - (KEY_IDENT_DIGITS * 2) - 3; if (statusbar->statusmsg_len > maxlen) { statusbar->statusmsg[maxlen - 3] = '\0'; diff --git a/src/device.c b/src/device.c index 74bf8c3..84bbd63 100644 --- a/src/device.c +++ b/src/device.c @@ -102,9 +102,7 @@ DeviceError init_devices() #endif /* AUDIO */ { const char *stringed_device_list; - - - + size[input] = 0; if ( (stringed_device_list = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER)) ) { ddevice_names[input] = alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); @@ -115,8 +113,6 @@ DeviceError init_devices() } } - - size[output] = 0; if ( (stringed_device_list = alcGetString(NULL, ALC_DEVICE_SPECIFIER)) ) { ddevice_names[output] = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); @@ -128,7 +124,6 @@ DeviceError init_devices() } // Start poll thread - if (pthread_mutex_init(&mutex, NULL) != 0) return de_InternalError; @@ -242,8 +237,10 @@ DeviceError open_device(DeviceType type, int32_t selection, uint32_t* device_idx } device->ref_count++; - if (pthread_mutex_init(device->mutex, NULL) != 0) + if (pthread_mutex_init(device->mutex, NULL) != 0) { + unlock; return de_InternalError; + } unlock; return de_None; @@ -296,8 +293,10 @@ DeviceError open_device(DeviceType type, int32_t selection, uint32_t* device_idx thread_paused = false; } - if (pthread_mutex_init(device->mutex, NULL) != 0) + if (pthread_mutex_init(device->mutex, NULL) != 0) { + unlock; return de_InternalError; + } unlock; return de_None; diff --git a/src/log.c b/src/log.c index b73b2df..0de22da 100644 --- a/src/log.c +++ b/src/log.c @@ -158,7 +158,7 @@ void load_chat_history(ToxWindow *self, struct chatlog *log) off_t sz = file_size(log->path); - if (sz == 0) + if (sz <= 0) return; char *hstbuf = malloc(sz); @@ -195,7 +195,7 @@ void load_chat_history(ToxWindow *self, struct chatlog *log) return; } - while (line != NULL) { + while (line != NULL && count--) { line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", line); line = strtok(NULL, "\n"); }