]> code.ossystems Code Review - openembedded-core.git/commitdiff
lib/oe/recipeutils: fix patch_recipe*() with empty input
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Mon, 25 Jul 2016 08:47:17 +0000 (20:47 +1200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 8 Nov 2016 23:03:16 +0000 (23:03 +0000)
If you supplied an empty file to patch_recipe() (or an empty list to
patch_recipe_lines()) then the result was IndexError because the code
checking to see if it needed to add an extra line of padding didn't
check to see if there were in fact any lines before trying to access the
last line.

Fixes [YOCTO #9972].

(From OE-Core rev: 92a73e870478ddb2a2d137e3fff28828809bec2e)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
meta/lib/oe/recipeutils.py

index 6c7adb5bdbf967a69dfd8408c9e1dc08410bca11..304989cfc56a9852b7205f0e11f1e95b6681ff14 100644 (file)
@@ -255,7 +255,7 @@ def patch_recipe_file(fn, values, patch=False, relpath=''):
     changed, tolines = bb.utils.edit_metadata(fromlines, varlist, patch_recipe_varfunc, match_overrides=True)
 
     if remainingnames:
-        if tolines[-1].strip() != '':
+        if tolines and tolines[-1].strip() != '':
             tolines.append('\n')
         for k in remainingnames.keys():
             outputvalue(k, tolines)