summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian C. Lane <bcl@redhat.com>2023-02-15 11:15:28 -0800
committerBrian C. Lane <bcl@redhat.com>2023-02-15 11:15:28 -0800
commit09c95d2feab0c087339886134dfe2dc04094348a (patch)
tree1b87143b9b1204a44886f4ebfae54dc9e753117e
parent9cb38a7444d02023d112ae8e9e38436104f75f64 (diff)
downloadparted-09c95d2feab0c087339886134dfe2dc04094348a.tar.gz
ui: Add checks for prompt being NULL
Also removes a cast from const char* to char* when passing to readline that doesn't appear to be necessary any longer. Added asserts to make sure prompt isn't NULL after strdup and realloc calls.
-rw-r--r--parted/ui.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/parted/ui.c b/parted/ui.c
index df14e55..9e5ced2 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -564,8 +564,7 @@ _readline (const char* prompt, const StrList* possibilities)
wipe_line ();
#ifdef HAVE_LIBREADLINE
if (!opt_script_mode) {
- /* XXX: why isn't prompt const? */
- line = readline ((char*) prompt);
+ line = readline (prompt);
if (line)
_add_history_unique (line);
} else
@@ -781,6 +780,8 @@ realloc_and_cat (char* str, const char* append)
int length = strlen (str) + strlen (append) + 1;
char* new_str = realloc (str, length);
+ PED_ASSERT(new_str != NULL);
+
strcat (new_str, append);
return new_str;
}
@@ -789,7 +790,9 @@ static char*
_construct_prompt (const char* head, const char* def,
const StrList* possibilities)
{
+ PED_ASSERT(head != NULL);
char* prompt = strdup (head);
+ PED_ASSERT(prompt != NULL);
if (def && possibilities)
PED_ASSERT (str_list_match_any (possibilities, def));