mirror of
https://github.com/ipxe/ipxe
synced 2025-12-20 12:00:19 +03:00
[settings] Eliminate variable-length stack allocation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -370,12 +370,14 @@ const char * settings_name ( struct settings *settings ) {
|
|||||||
static struct settings *
|
static struct settings *
|
||||||
parse_settings_name ( const char *name, get_child_settings_t get_child ) {
|
parse_settings_name ( const char *name, get_child_settings_t get_child ) {
|
||||||
struct settings *settings = &settings_root;
|
struct settings *settings = &settings_root;
|
||||||
char name_copy[ strlen ( name ) + 1 ];
|
char *name_copy;
|
||||||
char *subname;
|
char *subname;
|
||||||
char *remainder;
|
char *remainder;
|
||||||
|
|
||||||
/* Create modifiable copy of name */
|
/* Create modifiable copy of name */
|
||||||
memcpy ( name_copy, name, sizeof ( name_copy ) );
|
name_copy = strdup ( name );
|
||||||
|
if ( ! name_copy )
|
||||||
|
return NULL;
|
||||||
remainder = name_copy;
|
remainder = name_copy;
|
||||||
|
|
||||||
/* Parse each name component in turn */
|
/* Parse each name component in turn */
|
||||||
@@ -389,6 +391,9 @@ parse_settings_name ( const char *name, get_child_settings_t get_child ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free modifiable copy of name */
|
||||||
|
free ( name_copy );
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user