1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

db: fix inserting null in database

This commit is contained in:
Michael Vetter 2020-03-24 11:16:04 +01:00
parent dc0b7b5e91
commit c56443fea5

View File

@ -153,7 +153,7 @@ log_database_add(ProfMessage *message, gboolean is_muc) {
//gchar *date_fmt = g_date_time_format_iso8601(message->timestamp);
gchar *date_fmt = g_date_time_format(message->timestamp, "%Y/%m/%d %H:%M:%S");
if (asprintf(&query, "INSERT INTO `ChatLogs` (`jid`, `resource`, `message`, `timestamp`, `is_muc`, `stanza_id`, `replace_id`) VALUES ('%s', '%s', '%s', '%s', '%d', '%s', '%s')",
message->jid->barejid, message->jid->resourcepart, message->plain, date_fmt, is_muc, message->id, message->replace_id) == -1) {
message->jid->barejid, message->jid->resourcepart, message->plain, date_fmt, is_muc, message->id ? message->id : "", message->replace_id ? message->replace_id : "") == -1) {
log_error("log_database_add(): could not allocate memory");
return;
}