about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-03-25 16:46:18 +0100
committerMichael Vetter <jubalh@iodoru.org>2021-03-25 16:46:18 +0100
commit901f9d3d8cc7b1196ed72427e51ff1b137d02e71 (patch)
treeb66b39eafe07a629994f1826a80b34df5bc168fd /src
parente93d4ff33112e1b79f0eebaedff1639a0a0f3b08 (diff)
downloadprofani-tty-901f9d3d8cc7b1196ed72427e51ff1b137d02e71.tar.gz
database: make log_database_get_previous_chat safer
Diffstat (limited to 'src')
-rw-r--r--src/database.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/database.c b/src/database.c
index c04fea72..56e28135 100644
--- a/src/database.c
+++ b/src/database.c
@@ -214,6 +214,8 @@ log_database_get_previous_chat(const gchar* const contact_barejid)
     char* query;
     const char* jid = connection_get_fulljid();
     Jid* myjid = jid_create(jid);
+    if (!myjid)
+        return NULL;
 
     if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid`, `type` from `ChatLogs` WHERE (`from_jid` = '%s' AND `to_jid` = '%s') OR (`from_jid` = '%s' AND `to_jid` = '%s') ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid) == -1) {
         log_error("log_database_get_previous_chat(): SQL query. could not allocate memory");