]> ToastFreeware Gitweb - gregoa/bti.git/blobdiff - bti.c
bti: fix a crash for echo -n|bti
[gregoa/bti.git] / bti.c
diff --git a/bti.c b/bti.c
index 02b8aea5c0d8b231871ede345e68384b301f044f..c0c580443ba16e2177b391706ac29c38261da023 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -144,7 +144,8 @@ static char *get_string(const char *name)
        if (!fgets(string, 999, stdin))
                return NULL;
        temp = strchr(string, '\n');
-       *temp = '\0';
+       if (temp)
+               *temp = '\0';
        return string;
 }
 
@@ -749,7 +750,8 @@ static char *get_string_from_stdin(void)
        if (!fgets(string, 999, stdin))
                return NULL;
        temp = strchr(string, '\n');
-       *temp = '\0';
+       if (temp)
+               *temp = '\0';
        return string;
 }