narray 0.6.0.0 → 0.6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/src/ChangeLog +6 -1
- data/src/narray.c +9 -3
- data/src/narray.h +2 -2
- metadata +1 -1
data/src/ChangeLog
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
2011-08-29 Masahiro TANAKA <masa16.tanaka@gmail.com>
|
2
|
+
|
3
|
+
* narray.c (na_alloc_struct): check array size (zero/negative).
|
4
|
+
* ver 0.6.0.1
|
5
|
+
|
1
6
|
2011-08-27 Masahiro TANAKA <masa16.tanaka@gmail.com>
|
2
7
|
|
3
|
-
* narray.c (na_alloc_struct): check array size.
|
8
|
+
* narray.c (na_alloc_struct): check array size (overflow).
|
4
9
|
* extconf.rb (#install_rb): --export-all option for mingw.
|
5
10
|
* ver 0.6.0.0
|
6
11
|
|
data/src/narray.c
CHANGED
@@ -122,9 +122,15 @@ struct NARRAY*
|
|
122
122
|
struct NARRAY *ary;
|
123
123
|
|
124
124
|
for (i=0; i<rank; ++i) {
|
125
|
+
if (shape[i] < 0) {
|
126
|
+
rb_raise(rb_eArgError, "negative array size");
|
127
|
+
} else if (shape[i] == 0) {
|
128
|
+
total = 0;
|
129
|
+
break;
|
130
|
+
}
|
125
131
|
total_bak = total;
|
126
|
-
total
|
127
|
-
if (total>2147483647 || total/shape[i] != total_bak) {
|
132
|
+
total *= shape[i];
|
133
|
+
if (total < 1 || total > 2147483647 || total/shape[i] != total_bak) {
|
128
134
|
rb_raise(rb_eArgError, "array size is too large");
|
129
135
|
}
|
130
136
|
}
|
@@ -141,7 +147,7 @@ struct NARRAY*
|
|
141
147
|
else {
|
142
148
|
memsz = na_sizeof[type] * total;
|
143
149
|
|
144
|
-
if (memsz>2147483647 || memsz/na_sizeof[type] != total) {
|
150
|
+
if (memsz < 1 || memsz > 2147483647 || memsz/na_sizeof[type] != total) {
|
145
151
|
rb_raise(rb_eArgError, "allocation size is too large");
|
146
152
|
}
|
147
153
|
|
data/src/narray.h
CHANGED