From: Paul Eggleton Date: Mon, 25 Jul 2016 08:47:17 +0000 (+1200) Subject: lib/oe/recipeutils: fix patch_recipe*() with empty input X-Git-Tag: uninative-1.3~165 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=92a73e870478ddb2a2d137e3fff28828809bec2e;p=openembedded-core.git lib/oe/recipeutils: fix patch_recipe*() with empty input 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]. Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 0e7abf833b..c77664f135 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -259,7 +259,7 @@ def patch_recipe_lines(fromlines, values, trailing_newline=True): 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)