63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 65d2f744f9546dd0ef24d4579ca722afadf41c52 Mon Sep 17 00:00:00 2001
 | |
| From: Peter Jones <pjones@redhat.com>
 | |
| Date: Thu, 25 Sep 2014 13:24:15 -0400
 | |
| Subject: [PATCH 9/9] 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 855464a..27b4547 100644
 | |
| --- a/grubby.c
 | |
| +++ b/grubby.c
 | |
| @@ -2369,9 +2369,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);
 | |
| +	}
 | |
|      }
 | |
|  
 | |
|      for (j = 0, line = entry->lines; line; line = line->next) {
 | |
| @@ -3322,9 +3324,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)) {
 | |
| @@ -3372,9 +3378,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)) {
 | |
| -- 
 | |
| 1.9.3
 | |
| 
 |