Change in libosmocore[master]: get_value_string(): guard against NULL

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Feb 15 03:01:54 UTC 2019


Neels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/12879 )

Change subject: get_value_string(): guard against NULL
......................................................................

get_value_string(): guard against NULL

get_value_string() conveniently prints the value number to a static buffer if
it is unknown in a value_string array. Do the same if the value_string array
pointer itself is NULL.

If a value string array is user supplied and might be NULL, one could add a
separate NULL check around it; but by making get_value_string() itself guard
against NULL, another static char buffer to print the value number is avoided.

Change-Id: Ie640e9258a959da8f4f9089478de993509853997
---
M src/utils.c
1 file changed, 3 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Max: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/utils.c b/src/utils.c
index 0b2ed31..2d5bcb0 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -73,6 +73,9 @@
 {
 	int i;
 
+	if (!vs)
+		return NULL;
+
 	for (i = 0;; i++) {
 		if (vs[i].value == 0 && vs[i].str == NULL)
 			break;

-- 
To view, visit https://gerrit.osmocom.org/12879
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie640e9258a959da8f4f9089478de993509853997
Gerrit-Change-Number: 12879
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190215/f0e3e4b3/attachment.htm>


More information about the gerrit-log mailing list