From 9549dc0d747d8987dd11643340adfa7b6f799460 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 25 Sep 2014 13:24:15 -0400
Subject: [PATCH 24/41] Always error check getLineByType()
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/grubby.c b/grubby.c
index f8e9c25..febc1ad 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2363,9 +2363,11 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) {
} else {
char * title;
line = getLineByType(LT_MENUENTRY, entry->lines);
- title = grub2ExtractTitle(line);
- if (title)
- printf("title=%s\n", title);
+ if (!line) {
+ title = grub2ExtractTitle(line);
+ if (title)
+ printf("title=%s\n", title);
+ }
}
}
@@ -3302,9 +3304,13 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
/* if title is supplied, the entry's title must match it. */
if (title) {
+ char *linetitle;
+
line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
- char *linetitle = extractTitle(line);
+ if (!line)
+ continue;
+ linetitle = extractTitle(line);
if (!linetitle)
continue;
if (strcmp(title, linetitle)) {
@@ -3352,9 +3358,13 @@ int updateInitrd(struct grubConfig * cfg, const char * image,
/* if title is supplied, the entry's title must match it. */
if (title) {
+ char *linetitle;
+
line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
- char *linetitle = extractTitle(line);
+ if (!line)
+ continue;
+ linetitle = extractTitle(line);
if (!linetitle)
continue;
if (strcmp(title, linetitle)) {
--
2.4.3