From de942fba1cb7b1873e8813732f12a5475965c2ff Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 21 Feb 2012 16:49:51 +0200 Subject: [PATCH] Raise exception in python on headerGet() invalid data failure --- python/header-py.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/header-py.c b/python/header-py.c index 2610344..d194fdc 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -481,9 +481,13 @@ static PyObject * hdrGetTag(Header h, rpmTagVal tag) PyObject *res = NULL; struct rpmtd_s td; - /* rpmtd_AsPyobj() knows how to handle empty containers and all */ (void) headerGet(h, tag, &td, HEADERGET_EXT); - res = rpmtd_AsPyobj(&td); + if (rpmtdGetFlags(&td) & RPMTD_INVALID) { + PyErr_SetString(pyrpmError, "invalid header data"); + } else { + /* rpmtd_AsPyobj() knows how to handle empty containers and all */ + res = rpmtd_AsPyobj(&td); + } rpmtdFreeData(&td); return res; } -- 2.7.4