From 7c007561e7031f5e33b91a8baf51bb952693a2d0 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 26 Mar 2016 22:28:27 +0000 Subject: [PATCH] blob_get_name_by_id(): Treat id of dummy row as invalid. If the given id equals the id of the dummy row, the function currently returns an empty object. This is unfortunate, since blob table users should not know about the dummy row implementation detail. This patch makes the function return -E_DUMMY_ROW instead. In error.h, the E_DUMMY_ROW error code was defined in the section for mood.c because this file contains the only user of the error code. With another user in blob.c it seems appropriate to move it to the blob section instead. --- blob.c | 2 ++ error.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/blob.c b/blob.c index 2e0a4762..ca39de0d 100644 --- a/blob.c +++ b/blob.c @@ -496,6 +496,8 @@ static int blob_get_name_by_id(struct osl_table *table, uint32_t id, ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj)); if (ret < 0) return ret; + if (*(char *)obj.data == '\0') + return -E_DUMMY_ROW; *name = (char *)obj.data; return 1; } diff --git a/error.h b/error.h index b7352333..830d0f8d 100644 --- a/error.h +++ b/error.h @@ -246,7 +246,6 @@ extern const char **para_errlist[]; #define MOOD_ERRORS \ PARA_ERROR(NO_MOOD, "no mood available"), \ - PARA_ERROR(DUMMY_ROW, "attempted to access blob dummy object"), \ #define MM_ERRORS \ @@ -261,6 +260,7 @@ extern const char **para_errlist[]; #define BLOB_ERRORS \ PARA_ERROR(BLOB_SYNTAX, "blob syntax error"), \ + PARA_ERROR(DUMMY_ROW, "attempted to access blob dummy object"), \ #define PLAYLIST_ERRORS \ -- 2.39.2