From f13844810045989891245437b3a7ee8e231b14b6 Mon Sep 17 00:00:00 2001 From: leca Date: Mon, 13 Feb 2023 11:17:52 +0300 Subject: [PATCH] Fixed segfault --- .gitignore | 2 ++ main.c | 4 ++-- test.txt | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index cd531cf..4ea4f31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +test.txt + # ---> C # Prerequisites *.d diff --git a/main.c b/main.c index 3e82081..3893811 100644 --- a/main.c +++ b/main.c @@ -33,7 +33,7 @@ int main (int argc, char* argv[]) { noecho(); char ch = ' '; int len = 0; - char* cmd_string = malloc(cols); + char* cmd_string = malloc(128); char (*content)[cols] = malloc(sizeof(char[rows][cols+1])); for (int i = 0; i < rows; i ++) { @@ -52,7 +52,7 @@ int main (int argc, char* argv[]) { insertInStartContent(content, cmd_string); len = 0; clearInput(rows, cols); - cmd_string = ""; + cmd_string = malloc(128); refresh(); break; } diff --git a/test.txt b/test.txt index 08a7839..2895577 100644 --- a/test.txt +++ b/test.txt @@ -1 +1 @@ -test: test \ No newline at end of file +test: aadsd test \ No newline at end of file