Add terminating null to name of philo's semaphore
authorLukas Jiriste <ljiriste@student.42prague.com>
Tue, 28 May 2024 12:31:03 +0000 (14:31 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Tue, 28 May 2024 12:31:03 +0000 (14:31 +0200)
Otherwise the program may reach memory it should not.

philo_bonus/helpers.c

index f8caa764e640f1286462886ca4139cc61922a789..c7e54b0cb5f172c305bb485bd75ef7b3f6e9d94e 100644 (file)
@@ -77,6 +77,7 @@ char  *create_philo_sem_name(unsigned int id)
                name[i + j] = id_str[j];
                ++j;
        }
+       name[i + j] = '\0';
        free(id_str);
        return (name);
 }