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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged.
Change subject: core/conv/viterbi.c: fix possible NULL-pointer reference
......................................................................
core/conv/viterbi.c: fix possible NULL-pointer reference
Change-Id: I36012d4443d97470050cdf9638a9d4cf67ea3b40
---
M src/viterbi.c
1 file changed, 16 insertions(+), 3 deletions(-)
Approvals:
Harald Welte: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/viterbi.c b/src/viterbi.c
index 854754c..308cfe0 100644
--- a/src/viterbi.c
+++ b/src/viterbi.c
@@ -394,12 +394,15 @@
int olen = (code->N == 2) ? 2 : 4;
trellis = (struct vtrellis *) calloc(1, sizeof(struct vtrellis));
+ if (!trellis)
+ goto fail;
+
trellis->num_states = ns;
trellis->sums = vdec_malloc(ns);
trellis->outputs = vdec_malloc(ns * olen);
trellis->vals = (uint8_t *) malloc(ns * sizeof(uint8_t));
- if (!trellis->sums || !trellis->outputs)
+ if (!trellis->sums || !trellis->outputs || !trellis->vals)
goto fail;
/* Populate the trellis state objects */
@@ -507,9 +510,13 @@
if (!dec)
return;
- vdec_free(dec->paths[0]);
- free(dec->paths);
free_trellis(dec->trellis);
+
+ if (dec->paths != NULL) {
+ vdec_free(dec->paths[0]);
+ free(dec->paths);
+ }
+
free(dec);
}
@@ -572,7 +579,13 @@
goto fail;
dec->paths = (int16_t **) malloc(sizeof(int16_t *) * dec->len);
+ if (!dec->paths)
+ goto fail;
+
dec->paths[0] = vdec_malloc(ns * dec->len);
+ if (!dec->paths[0])
+ goto fail;
+
for (i = 1; i < dec->len; i++)
dec->paths[i] = &dec->paths[0][i * ns];
--
To view, visit https://gerrit.osmocom.org/2876
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I36012d4443d97470050cdf9638a9d4cf67ea3b40
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>