diff options
author | Michael Vetter <jubalh@iodoru.org> | 2021-03-25 16:46:18 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2021-03-25 16:46:18 +0100 |
commit | 901f9d3d8cc7b1196ed72427e51ff1b137d02e71 (patch) | |
tree | b66b39eafe07a629994f1826a80b34df5bc168fd | |
parent | e93d4ff33112e1b79f0eebaedff1639a0a0f3b08 (diff) | |
download | profani-tty-901f9d3d8cc7b1196ed72427e51ff1b137d02e71.tar.gz |
database: make log_database_get_previous_chat safer
-rw-r--r-- | src/database.c | 2 |
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"); |