aboutsummaryrefslogtreecommitdiffstats
path: root/src/lush.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lush.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lush.c b/src/lush.c
index aa1b90f..33f7beb 100644
--- a/src/lush.c
+++ b/src/lush.c
@@ -195,11 +195,13 @@ static void reprint_buffer(char *buffer, int *last_lines, int *pos,
// handle history before doing calculations
if (history_pos >= 0) {
char *history_line = lush_get_past_command(history_pos);
- strncpy(buffer, history_line, BUFFER_SIZE);
- free(history_line);
- // remove newline from buffer
- buffer[strlen(buffer) - 1] = '\0';
- *pos = strlen(buffer);
+ if (history_line != NULL) {
+ strncpy(buffer, history_line, BUFFER_SIZE);
+ free(history_line);
+ // remove newline from buffer
+ buffer[strlen(buffer) - 1] = '\0';
+ *pos = strlen(buffer);
+ }
}
int num_lines = ((strlen(buffer) + strlen(prompt) + 1) / width) + 1;
> 2011-07-14efficiency tweaksGravatar Connor Lane Smith 2-60/+44 2011-07-14fix extra warningGravatar Connor Lane Smith 1-1/+1 2011-07-06simpler vlineGravatar Connor Lane Smith 1-4/+2 2011-07-04rebind ^N ^PGravatar Connor Lane Smith 2-3/+3 2011-06-25include limits.hGravatar Connor Lane Smith 1-0/+1 2011-06-23make clean lsxGravatar Connor Lane Smith 1-1/+1 2011-06-23lsx: check snprintfGravatar Connor Lane Smith 1-4/+3 2011-06-18update draw.cGravatar Connor Lane Smith 2-14/+14 2011-06-18simpler lsxGravatar Connor Lane Smith 3-11/+6 2011-06-13new dmenu_runGravatar Connor Lane Smith 5-26/+15