Jump to content

Memory allocating: Q_Strncpyz: NULL dest


Go to solution Solved by Exmirai,

Recommended Posts

code: 

menuDef_t *UI_CreateMenu(const char *name){
	if (menuCount < MAX_MENUS) {
		menuDef_t *menu = &Menus[menuCount];
		menu = (menuDef_t*)malloc(sizeof(menuDef_t));
		Menu_Init(menu);
		menu->itemCount = 0;
		Q_strncpyz(menu->window.name, name, sizeof(menu->window.name));
		menuCount++;
		return menu;
	}
	return NULL;
}

When I run this code, the game crashes with an error Q_Strncpyz: NULL dest, I understand the error, but can not understand exactly where I was wrong. What's the matter?

spior likes this
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...