From 60509688527efdf2a90b2d4241034a9775898940 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Mon, 12 Nov 2018 13:03:04 +0100 Subject: fix bogus error check in gprs_sndcp_comp_create() The function gprs_sndcp_get_compression_class() returns -EINVAL upon error, not -1, so an existing assertion would never trigger. Instead, check for the values we want first (PROTOCOL_COMP or DATA_COMP) and assert(false) in case the returned value doesn't match either of these. Found by: Neels Change-Id: I8444c1ed052707c76a979fb06cb018ac678defa7 --- src/gprs/gprs_sndcp_comp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gprs/gprs_sndcp_comp.c b/src/gprs/gprs_sndcp_comp.c index 60b15b92e..3e026032e 100644 --- a/src/gprs/gprs_sndcp_comp.c +++ b/src/gprs/gprs_sndcp_comp.c @@ -92,19 +92,20 @@ static struct gprs_sndcp_comp *gprs_sndcp_comp_create(const void *ctx, * (Protocol or Data compresson ?) */ comp_entity->compclass = gprs_sndcp_get_compression_class(comp_field); - OSMO_ASSERT(comp_entity->compclass != -1); - /* Create an algorithm specific compression context */ if (comp_entity->compclass == SNDCP_XID_PROTOCOL_COMPRESSION) { if (gprs_sndcp_pcomp_init(ctx, comp_entity, comp_field) != 0) { talloc_free(comp_entity); comp_entity = NULL; } - } else { + } else if (comp_entity->compclass == SNDCP_XID_DATA_COMPRESSION) { if (gprs_sndcp_dcomp_init(ctx, comp_entity, comp_field) != 0) { talloc_free(comp_entity); comp_entity = NULL; } + } else { + /* comp_field is somehow invalid */ + OSMO_ASSERT(false); } /* Bail on failure */ -- cgit v1.2.3