added error checking for malloc

This commit is contained in:
Roland W-H 2022-11-18 10:33:42 +00:00
parent 4c9614342e
commit 7fe3d3c107
1 changed files with 5 additions and 3 deletions

View File

@ -16,9 +16,11 @@
char* dyninput_str(int_least64_t maxsize)
{
char* str = malloc(3 * sizeof(char));
/*if (!str)
puts("Error allocating memory!");
return NULL;*/
if (!str)
{
puts("\nError allocating memory!");
return NULL;
}
int_least64_t size = 3, i = 0;
char c = 0;