mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
fixed segfault when home directory doesn't exist
This commit is contained in:
parent
cd4f4d0b1a
commit
2fc588be17
10
src/log.c
10
src/log.c
@ -131,13 +131,15 @@ void
|
|||||||
log_close(void)
|
log_close(void)
|
||||||
{
|
{
|
||||||
g_time_zone_unref(tz);
|
g_time_zone_unref(tz);
|
||||||
|
if (logp != NULL) {
|
||||||
fclose(logp);
|
fclose(logp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
log_msg(log_level_t level, const char * const area, const char * const msg)
|
log_msg(log_level_t level, const char * const area, const char * const msg)
|
||||||
{
|
{
|
||||||
if (level >= level_filter) {
|
if (level >= level_filter && logp != NULL) {
|
||||||
long result;
|
long result;
|
||||||
dt = g_date_time_new_now(tz);
|
dt = g_date_time_new_now(tz);
|
||||||
|
|
||||||
@ -238,7 +240,7 @@ chat_log_chat(const gchar * const login, gchar *other,
|
|||||||
date_fmt = g_date_time_format(dt, "%H:%M:%S");
|
date_fmt = g_date_time_format(dt, "%H:%M:%S");
|
||||||
|
|
||||||
FILE *logp = fopen(dated_log->filename, "a");
|
FILE *logp = fopen(dated_log->filename, "a");
|
||||||
|
if (logp != NULL) {
|
||||||
if (direction == PROF_IN_LOG) {
|
if (direction == PROF_IN_LOG) {
|
||||||
if (strncmp(msg, "/me ", 4) == 0) {
|
if (strncmp(msg, "/me ", 4) == 0) {
|
||||||
fprintf(logp, "%s - *%s %s\n", date_fmt, other, msg + 4);
|
fprintf(logp, "%s - *%s %s\n", date_fmt, other, msg + 4);
|
||||||
@ -257,6 +259,7 @@ chat_log_chat(const gchar * const login, gchar *other,
|
|||||||
if (result == EOF) {
|
if (result == EOF) {
|
||||||
log_error("Error closing file %s, errno = %d", dated_log->filename, errno);
|
log_error("Error closing file %s, errno = %d", dated_log->filename, errno);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_free(date_fmt);
|
g_free(date_fmt);
|
||||||
g_date_time_unref(dt);
|
g_date_time_unref(dt);
|
||||||
@ -285,7 +288,7 @@ groupchat_log_chat(const gchar * const login, const gchar * const room,
|
|||||||
gchar *date_fmt = g_date_time_format(dt, "%H:%M:%S");
|
gchar *date_fmt = g_date_time_format(dt, "%H:%M:%S");
|
||||||
|
|
||||||
FILE *logp = fopen(dated_log->filename, "a");
|
FILE *logp = fopen(dated_log->filename, "a");
|
||||||
|
if (logp != NULL) {
|
||||||
if (strncmp(msg, "/me ", 4) == 0) {
|
if (strncmp(msg, "/me ", 4) == 0) {
|
||||||
fprintf(logp, "%s - *%s %s\n", date_fmt, nick, msg + 4);
|
fprintf(logp, "%s - *%s %s\n", date_fmt, nick, msg + 4);
|
||||||
} else {
|
} else {
|
||||||
@ -297,6 +300,7 @@ groupchat_log_chat(const gchar * const login, const gchar * const room,
|
|||||||
if (result == EOF) {
|
if (result == EOF) {
|
||||||
log_error("Error closing file %s, errno = %d", dated_log->filename, errno);
|
log_error("Error closing file %s, errno = %d", dated_log->filename, errno);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_free(date_fmt);
|
g_free(date_fmt);
|
||||||
g_date_time_unref(dt);
|
g_date_time_unref(dt);
|
||||||
|
Loading…
Reference in New Issue
Block a user