From 891ccac3b62b2677623696b8dbdf03a27611bf1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Fri, 15 Jan 2021 16:45:12 +0200 Subject: [PATCH] escl: fix char_to_array memory allocation calculations Too little memory allocated due to incorrect calculation. Fixes #425 --- backend/escl/escl_capabilities.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/escl/escl_capabilities.c b/backend/escl/escl_capabilities.c index 95467773f..08e2bd10d 100644 --- a/backend/escl/escl_capabilities.c +++ b/backend/escl/escl_capabilities.c @@ -90,9 +90,9 @@ char_to_array(SANE_String_Const *tab, int *tabsize, SANE_String_Const mode, int } (*tabsize)++; if (*tabsize == 1) - board = (SANE_String_Const *)malloc(sizeof(SANE_String_Const) * (*tabsize) + 1); + board = (SANE_String_Const *)malloc(sizeof(SANE_String_Const) * ((*tabsize) + 1)); else - board = (SANE_String_Const *)realloc(tab, sizeof(SANE_String_Const) * (*tabsize) + 1); + board = (SANE_String_Const *)realloc(tab, sizeof(SANE_String_Const) * ((*tabsize) + 1)); board[*tabsize - 1] = (SANE_String_Const)strdup(convert); board[*tabsize] = NULL; return (board);