From 83063037ac518f699a1c0bd9be595a1107f295fd Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 1 Jul 2024 10:26:22 +0300 Subject: [PATCH] fixed --- plainbin.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/plainbin.c b/plainbin.c index 8d08e41..1adaac9 100644 --- a/plainbin.c +++ b/plainbin.c @@ -20,7 +20,7 @@ #define MSG4 "No namespace available.\n" #ifndef VERSION -#define VERSION "1" +#define VERSION "1.1" #endif int iport = 8080; @@ -99,7 +99,7 @@ char *rand_string(void) { } char *rand_name(void) { - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 1000; i++) { char *filename = rand_string(); if (filename == NULL) continue; @@ -186,15 +186,17 @@ void upload(int cfd, pid_t par) { /* Clear */ UPL_ERROR: - if (buf != NULL) + if (buf) free(buf); if (ffd != -1) close(ffd); if (ret == -1) - fprintf(stderr, "%s: input thread: %s: %s\n", prog_name, filename, strerror(errno)); - free(filename); + fprintf(stderr, "%s: input thread: %s: %s\n", prog_name, (filename) ? filename : "NULL", strerror(errno)); + + if (filename) + free(filename); close(cfd); kill(par, SIGUSR1); @@ -267,15 +269,17 @@ void load(int cfd, pid_t par) { /* Clear */ LD_ERROR: - if (buf != NULL) + if (buf) free(buf); if (ffd != -1) close(ffd); if (ret == -1) - fprintf(stderr, "%s: output thread: %s: %s\n", prog_name, filename, strerror(errno)); - free(filename); + fprintf(stderr, "%s: output thread: %s: %s\n", prog_name, (filename) ? filename : "NULL", strerror(errno)); + + if (filename) + free(filename); sleep(1); close(cfd);