Skip to content

Commit

Permalink
Fix bug where sometimes it would crash for certain filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
terhechte committed Feb 7, 2020
1 parent 98bb64b commit 46fbd0e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main.c
Expand Up @@ -496,8 +496,12 @@ void gitsi_add_entry(const char *filename, const char *description,
context->entries[pos] = calloc(1, sizeof(gitsi_status_entry));
if (filename != NULL)
context->entries[pos]->filename = strdup(filename);
else
context->entries[pos]->filename = NULL;
if (description != NULL)
context->entries[pos]->description = strdup(description);
else
context->entries[pos]->description = NULL;
context->entries[pos]->type = type;
}

Expand Down Expand Up @@ -1041,7 +1045,11 @@ void gitsi_print_list(gitsi_context *context) {
color_set(GITSI_COLOR_VISUAL_SELECT, 0);
mvprintw(pos, 0, " ");
} else {
mvprintw(pos, lpos, "%s\t%11s\t%s", is_marked ? "*" : " ", entries[i]->description, entries[i]->filename);
const char* filename = entries[i]->filename;
if (filename == NULL)filename = "";
const char* description = entries[i]->description;
if (description == NULL)description = "";
mvprintw(pos, lpos, "%s\t%11s\t%s", is_marked ? "*" : " ", filename, description);
color_set(GITSI_COLOR_VISUAL_SELECT, 0);
mvprintw(pos, 0, "%3d ", abs(middle - linum_pos));
linum_pos += 1;
Expand Down

0 comments on commit 46fbd0e

Please sign in to comment.