@@ -669,14 +669,14 @@ static char *conf_value_to_yaml(struct symbol *sym, const char *val)
yaml_value = strdup(val);
break;
case S_HEX:
- asprintf(&yaml_value, "0x%s", val);
- break;
- case S_STRING:
- /* Wrap strings in quotes */
- asprintf(&yaml_value, "\"%s\"", val);
- break;
- case S_BOOLEAN:
- case S_TRISTATE:
+ if (asprintf(&yaml_value, "0x%s", val) < 0)
+ return NULL;
+ case S_STRING:
+ /* Wrap strings in quotes */
+ if (asprintf(&yaml_value, "\"%s\"", val) < 0)
+ return NULL;
+ case S_BOOLEAN:
+ case S_TRISTATE:
if (strcmp(val, "y") == 0)
yaml_value = strdup("True");
else if (strcmp(val, "n") == 0)
The asprintf call returns -1 on error. In this case the value of yaml_value is undefined. Return NULL, so the caller can handle the error. Signed-off-by: Joel Granados <joel.granados@kernel.org> --- scripts/kconfig/confdata.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)