LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_init_multi.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 12 21 57.1 %
Date: 2024-04-21 15:09:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_INIT_MULTI_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : #include <stdarg.h>
       7             : 
       8        1061 : mp_err mp_init_multi(mp_int *mp, ...)
       9             : {
      10        1061 :    mp_err err = MP_OKAY;      /* Assume ok until proven otherwise */
      11        1061 :    int n = 0;                 /* Number of ok inits */
      12        1061 :    mp_int *cur_arg = mp;
      13          40 :    va_list args;
      14             : 
      15        1061 :    va_start(args, mp);        /* init args to next argument from caller */
      16        5861 :    while (cur_arg != NULL) {
      17        4800 :       if (mp_init(cur_arg) != MP_OKAY) {
      18             :          /* Oops - error! Back-track and mp_clear what we already
      19             :             succeeded in init-ing, then return error.
      20             :          */
      21           0 :          va_list clean_args;
      22             : 
      23             :          /* now start cleaning up */
      24           0 :          cur_arg = mp;
      25           0 :          va_start(clean_args, mp);
      26           0 :          while (n-- != 0) {
      27           0 :             mp_clear(cur_arg);
      28           0 :             cur_arg = va_arg(clean_args, mp_int *);
      29             :          }
      30           0 :          va_end(clean_args);
      31           0 :          err = MP_MEM;
      32           0 :          break;
      33             :       }
      34        4800 :       n++;
      35        4800 :       cur_arg = va_arg(args, mp_int *);
      36             :    }
      37        1061 :    va_end(args);
      38        1061 :    return err;                /* Assumed ok, if error flagged above. */
      39             : }
      40             : 
      41             : #endif

Generated by: LCOV version 1.14