From b24e3c93a2faa94b138739d1b3e8b631f8123492 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 13 Jun 2015 20:47:33 +0200 Subject: [PATCH] osl_get_nth_row(): Always initialize result pointer. We buy into Postel's prescription and try to be liberal in what we accept, and conservative in what we send. This patch makes sure the result pointer is set to NULL on failure, and documents this fact. --- osl.c | 1 + osl.h.in | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/osl.c b/osl.c index 80bec0f..6666196 100644 --- a/osl.c +++ b/osl.c @@ -1702,6 +1702,7 @@ __export int osl_get_nth_row(const struct osl_table *t, unsigned col_num, unsigned num_rows; int ret; + *result = NULL; if (n == 0) return -E_OSL_RB_KEY_NOT_FOUND; ret = osl_get_num_rows(t, &num_rows); diff --git a/osl.h.in b/osl.h.in index 5491a2c..17bfbc1 100644 --- a/osl.h.in +++ b/osl.h.in @@ -214,7 +214,8 @@ int osl_close_table(struct osl_table *t, enum osl_close_flags flags); * Lookup \a obj in \a t and return the row containing \a obj. The column * specified by \a col_num must have an associated rbtree. * - * \return Standard. + * \return Standard. \a result is set to \p NULL if and only if the function + * returns negative. * * \sa osl_storage_flags */ -- 2.39.2