method->container_unit = library_unit;
method_name = string_create();
method_name->length = constant_pool[method_name_index].data_len;
- method_name->cstr = malloc(method_name->length + 1);
- strcpy(method_name->cstr, constant_pool[method_name_index].data);
- method_name->cstr[method_name->length] = '\0';
+ // Strings in class has no null char
+ method_name->cstr = malloc(method_name->length + 2);
+ strncpy(method_name->cstr, constant_pool[method_name_index].data, method_name->length);
+ method_name->cstr[method_name->length + 1] = '\0';
name_table_insert(library_unit->names, method_name, method);
}