diff --git a/c-programming/strings/str_replace.c b/c-programming/strings/str_replace.c index 9a6c658..934a34c 100644 --- a/c-programming/strings/str_replace.c +++ b/c-programming/strings/str_replace.c @@ -47,10 +47,8 @@ char* str_replace( size_t new_len = strlen(str) + count * (replacement_len - substr_len); char* result = malloc((new_len + 1) * sizeof(char)); - if (result == NULL) { - perror("malloc"); - exit(EXIT_FAILURE); - } + if (result == NULL) + return NULL; const char* q = str; char* r = result;