/* PSPP - a program for statistical analysis.
- Copyright (C) 2021 Free Software Foundation, Inc.
+ Copyright (C) 2021, 2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
: end <= start && by < 0 ? (start - end - by) / -by
: 0);
gsl_matrix *m = gsl_matrix_alloc (1, n);
+ if (m == NULL)
+ {
+ msg_at (SE, matrix_expr_location (e),
+ _("Matrix cannot be allocated. Too large?"));
+ return NULL;
+ }
+
for (long int i = 0; i < n; i++)
gsl_matrix_set (m, 0, i, start + i * by);
return m;
7 | RELEASE x y.
| ^
])
-AT_CLEANUP
\ No newline at end of file
+AT_CLEANUP
+
+
+dnl Check that attempting to allocate huge matrices fails gracefully
+AT_SETUP([MATRIX - very large matrices])
+AT_DATA([matrix.sps], [dnl
+MATRIX.
+PRINT 2:230000000000.
+END MATRIX.
+])
+
+AT_CHECK([pspp matrix.sps], [1], [dnl
+matrix.sps:2.7-2.20: error: MATRIX: Matrix cannot be allocated. Too large?
+ 2 | PRINT 2:230000000000.
+ | ^~~~~~~~~~~~~~
+])
+
+AT_CLEANUP