From c179461ca588748bdafc92194d56b7c109c6aa32 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Wed, 11 Feb 2015 17:55:46 +0100 Subject: [PATCH] adg: return NULL instead of invalid data from adg_path_last_primitive AdgPath holds a private CpmlPrimitive struct that refers to the last primitive appended. If there is no such primitive this struct is 0-filled: return NULL from the API instead of this 0-filled struct. --- src/adg/adg-path.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/adg/adg-path.c b/src/adg/adg-path.c index 4c541d70..cdcfba68 100644 --- a/src/adg/adg-path.c +++ b/src/adg/adg-path.c @@ -265,7 +265,7 @@ adg_path_has_current_point(AdgPath *path) * Gets the last primitive appended to @path. The returned struct * is owned by @path and should not be freed or modified. * - * Returns: (transfer none): a pointer to the last appended primitive or NULL on errors. + * Returns: (transfer none): a pointer to the last appended primitive or NULL on no last primitive or on errors. * * Since: 1.0 **/ @@ -278,6 +278,10 @@ adg_path_last_primitive(AdgPath *path) data = path->data; + /* Directly return NULL instead of returning an undefined primitive */ + if (data->last.org == NULL || data->last.data == NULL) + return NULL; + return &data->last; } -- 2.11.4.GIT