diff --git a/src/common/shaderloader.hpp b/src/common/shaderloader.hpp index 1b874ee..71e63ff 100644 --- a/src/common/shaderloader.hpp +++ b/src/common/shaderloader.hpp @@ -39,7 +39,8 @@ struct ShaderRegistry { void register_shader(struct ShaderRegistry *r, char *name, int type, GLuint id) { // Allocate storage for the name int name_size = strlen(name); - char *n = (char*) malloc(name_size * sizeof(char)); + char *n = (char*) calloc(name_size, sizeof(char)); + strncpy(n, name, strlen(name)); // Grow and copy int new_size = r->size + 1; @@ -220,6 +221,7 @@ int loadShadersFromFile(const char* file_path, struct ShaderRegistry *registry) } // Add to registry + register_shader(registry, name, shader_type, shader_id); // Cleanup free(line_copy);