engine: fix flexible array member usage in case of null terminated strings
(woops)
This commit is contained in:
parent
4eaa32fc10
commit
20d4e3e719
2 changed files with 4 additions and 4 deletions
|
@ -26,7 +26,7 @@ struct base_command_hashmap_s
|
|||
base_command_t *basecmd; // base command: cvar, alias or command
|
||||
base_command_hashmap_t *next;
|
||||
base_command_type_e type; // type for faster searching
|
||||
char name[1]; // key for searching
|
||||
char name[]; // key for searching
|
||||
};
|
||||
|
||||
static base_command_hashmap_t *hashed_cmds[HASH_SIZE];
|
||||
|
@ -129,7 +129,7 @@ void BaseCmd_Insert( base_command_type_e type, base_command_t *basecmd, const ch
|
|||
uint hash = BaseCmd_HashKey( name );
|
||||
size_t len = Q_strlen( name );
|
||||
|
||||
elem = Mem_Malloc( basecmd_pool, sizeof( base_command_hashmap_t ) + len );
|
||||
elem = Mem_Malloc( basecmd_pool, sizeof( base_command_hashmap_t ) + len + 1 );
|
||||
elem->basecmd = basecmd;
|
||||
elem->type = type;
|
||||
Q_strncpy( elem->name, name, len + 1 );
|
||||
|
|
|
@ -709,7 +709,7 @@ int Cmd_AddCommandEx( const char *cmd_name, xcommand_t function, const char *cmd
|
|||
// unfortunately, we lose original command this way
|
||||
if( FBitSet( cmd->flags, CMD_OVERRIDABLE ))
|
||||
{
|
||||
desc_len = Q_strlen( cmd->desc );
|
||||
desc_len = Q_strlen( cmd->desc ) + 1;
|
||||
Q_strncpy( cmd->desc, cmd_desc, desc_len );
|
||||
cmd->function = function;
|
||||
cmd->flags = iFlags;
|
||||
|
@ -725,7 +725,7 @@ int Cmd_AddCommandEx( const char *cmd_name, xcommand_t function, const char *cmd
|
|||
}
|
||||
|
||||
// use a small malloc to avoid zone fragmentation
|
||||
desc_len = Q_strlen( cmd_desc );
|
||||
desc_len = Q_strlen( cmd_desc ) + 1;
|
||||
cmd = Mem_Malloc( cmd_pool, sizeof( cmd_t ) + desc_len );
|
||||
cmd->name = copystringpool( cmd_pool, cmd_name );
|
||||
Q_strncpy( cmd->desc, cmd_desc, desc_len );
|
||||
|
|
Loading…
Add table
Reference in a new issue