Skip to content

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhch committed Aug 17, 2024
1 parent 6fdde0f commit 36519fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ macOS 13|lldb|NO

### History

- v1.4 2024-08-17

Fix memory leak

- v1.3 2024-06-28

Add command parameter
Expand Down
9 changes: 6 additions & 3 deletions shellc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Function: Convert script into C code
* Author: ChenZhongChao
* Date: 2023-12-25
* Version: 1.3
* Version: 1.4
* Github: https://github.com/chenzhch/shellc.git
*/

Expand Down Expand Up @@ -242,6 +242,7 @@ static const char *fourth[] = {
" str = strdup(\"Failed to pipe\");",
" if (pipe(file) == -1) {",
" perror(str);",
" free(str);",
" return 1;",
" }",
" free(str);",
Expand Down Expand Up @@ -560,10 +561,12 @@ int main(int argc, char **argv)
struct utsname sysinfo;
struct stat status;
char *self_name = "/proc/self/status";
char *option = "f:e:b:p:tsh";
char option[32];
char **args = (char **) malloc((argc + 1) * sizeof(char *));
char *token;
char *usage = "command inputfile [-t] [-s] [-f fix-format] [-e fix-file] [-p parameter] [-b 8|16|32|64]";
memset(option, 0, sizeof(option));
strcat(option, "f:e:b:p:tsh");

j = 0;
args[j++] = strdup(argv[0]);
Expand Down Expand Up @@ -601,8 +604,8 @@ int main(int argc, char **argv)
printf(" -s Using safe mode\n");
printf(" -f Fix arguments format\n");
printf(" -e Fix arguments 0 by external file\n");
printf(" -b Operating system bits\n");
printf(" -p Command parameter\n");
printf(" -b Operating system bits\n");
printf(" -h Display help and return\n");
return(0);
case 't':
Expand Down
4 changes: 4 additions & 0 deletions 说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ macOS 13|lldb|不支持

### 修改记录

- v1.4 2024-08-17

修复内存泄露

- v1.3 2024-06-28

增加命令参数支持
Expand Down

0 comments on commit 36519fc

Please sign in to comment.