Check if category is NULL before copying it
This commit is contained in:
parent
93e29137f8
commit
22b90691b5
@ -59,7 +59,7 @@ sqlite3* get_db() {
|
|||||||
"CREATE TABLE tasks ( \
|
"CREATE TABLE tasks ( \
|
||||||
id INTEGER PRIMARY KEY,\
|
id INTEGER PRIMARY KEY,\
|
||||||
text TEXT NOT NULL,\
|
text TEXT NOT NULL,\
|
||||||
category TEXT DEFAULT '', \
|
category TEXT DEFAULT NULL, \
|
||||||
done INTEGER, \
|
done INTEGER, \
|
||||||
due_to INTEGER \
|
due_to INTEGER \
|
||||||
);",
|
);",
|
||||||
@ -202,8 +202,12 @@ void get_task(int id, task_t* t) {
|
|||||||
strcpy(t->text, text);
|
strcpy(t->text, text);
|
||||||
|
|
||||||
char* category = (char*)sqlite3_column_text(stmt, 4);
|
char* category = (char*)sqlite3_column_text(stmt, 4);
|
||||||
|
if (category) {
|
||||||
t->category = malloc(sizeof(char)*(strlen(category)+1));
|
t->category = malloc(sizeof(char)*(strlen(category)+1));
|
||||||
strcpy(t->category, category);
|
strcpy(t->category, category);
|
||||||
|
} else {
|
||||||
|
t->category = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlCheck( sqlite3_finalize(stmt) );
|
sqlCheck( sqlite3_finalize(stmt) );
|
||||||
@ -238,8 +242,13 @@ task_list_t* get_task_list(char* input_category, bool include_completed) {
|
|||||||
strcpy(t.text, text);
|
strcpy(t.text, text);
|
||||||
|
|
||||||
char* category = (char*)sqlite3_column_text(stmt, 4);
|
char* category = (char*)sqlite3_column_text(stmt, 4);
|
||||||
|
if (category) {
|
||||||
t.category = malloc(sizeof(char)*(strlen(category)+1));
|
t.category = malloc(sizeof(char)*(strlen(category)+1));
|
||||||
strcpy(t.category, category);
|
strcpy(t.category, category);
|
||||||
|
} else {
|
||||||
|
t.category = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
task_list_t* cur = malloc(sizeof(task_list_t)); // Add the parsed task to the beginning of the list
|
task_list_t* cur = malloc(sizeof(task_list_t)); // Add the parsed task to the beginning of the list
|
||||||
cur->task = t;
|
cur->task = t;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef DEF_CONFIG_H
|
#ifndef DEF_CONFIG_H
|
||||||
#define DEF_CONFIG_H
|
#define DEF_CONFIG_H
|
||||||
|
|
||||||
#define VERSION "1.2.1"
|
#define VERSION "1.3.0"
|
||||||
|
|
||||||
// By default, $HOME/.config/takl.sqlite3 is used. You can change this behaviour here
|
// By default, $HOME/.config/takl.sqlite3 is used. You can change this behaviour here
|
||||||
//#define DB_FILE "takl.sqlite3"
|
//#define DB_FILE "takl.sqlite3"
|
||||||
|
Loading…
Reference in New Issue
Block a user