summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Zimmermann <Paul.Zimmermann@inria.fr>2018-04-19 20:45:59 +0200
committerPaul Zimmermann <Paul.Zimmermann@inria.fr>2018-04-19 20:45:59 +0200
commit0576b43a711fb65c0a5e447dcf96081670f85e1e (patch)
treee1328ace707318689b9f22e743d6dbcee32cd0ab /src
parent0641b55b6a5665b2449c70a6073db722ad15269e (diff)
downloadmpc-git-0576b43a711fb65c0a5e447dcf96081670f85e1e.tar.gz
check return value of malloc() is not NULL in mpc_sum
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/mpc.h1
-rw-r--r--src/sum.c2
3 files changed, 5 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 97c7a06..c17c9da 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,7 +30,7 @@ libmpc_la_SOURCES = mpc-impl.h abs.c acos.c acosh.c add.c add_fr.c \
pow_ld.c pow_d.c pow_si.c pow_ui.c pow_z.c proj.c real.c rootofunity.c \
urandom.c set.c \
set_prec.c set_str.c set_x.c set_x_x.c sin.c sin_cos.c sinh.c sqr.c \
- sqrt.c strtoc.c sub.c sub_fr.c sub_ui.c swap.c tan.c tanh.c uceil_log2.c \
- ui_div.c ui_ui_sub.c
+ sqrt.c strtoc.c sub.c sub_fr.c sub_ui.c sum.c swap.c tan.c tanh.c \
+ uceil_log2.c ui_div.c ui_ui_sub.c
libmpc_la_LIBADD = @LTLIBOBJS@
diff --git a/src/mpc.h b/src/mpc.h
index 07da900..5252d9d 100644
--- a/src/mpc.h
+++ b/src/mpc.h
@@ -201,6 +201,7 @@ __MPC_DECLSPEC int mpc_asinh (mpc_ptr, mpc_srcptr, mpc_rnd_t);
__MPC_DECLSPEC int mpc_acosh (mpc_ptr, mpc_srcptr, mpc_rnd_t);
__MPC_DECLSPEC int mpc_atanh (mpc_ptr, mpc_srcptr, mpc_rnd_t);
__MPC_DECLSPEC int mpc_rootofunity (mpc_ptr, unsigned long int, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int mpc_sum (mpc_ptr, const mpc_ptr *, unsigned long, mpc_rnd_t);
__MPC_DECLSPEC void mpc_clear (mpc_ptr);
__MPC_DECLSPEC int mpc_urandom (mpc_ptr, gmp_randstate_t);
__MPC_DECLSPEC void mpc_init2 (mpc_ptr, mpfr_prec_t);
diff --git a/src/sum.c b/src/sum.c
index 9cebe12..243286c 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -18,6 +18,7 @@ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see http://www.gnu.org/licenses/ .
*/
+#include <stdio.h> /* for MPC_ASSERT */
#include "mpc-impl.h"
int
@@ -28,6 +29,7 @@ mpc_sum (mpc_ptr sum, const mpc_ptr *z, unsigned long n, mpc_rnd_t rnd)
unsigned long i;
t = (mpfr_ptr *) malloc (n * sizeof(mpfr_t));
+ MPC_ASSERT(t != NULL);
for (i = 0; i < n; i++)
t[i] = mpc_realref (z[i]);
inex_re = mpfr_sum (mpc_realref (sum), t, n, MPC_RND_RE (rnd));