From: Andre Noll Date: Sat, 13 Jun 2015 18:47:33 +0000 (+0200) Subject: osl_get_nth_row(): Always initialize result pointer. X-Git-Tag: v0.1.3~13 X-Git-Url: http://git.tuebingen.mpg.de/?p=osl.git;a=commitdiff_plain;h=b24e3c93a2faa94b138739d1b3e8b631f8123492;ds=sidebyside 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. --- 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 */