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.
Files changed (4) hide show
  1. data/src/ChangeLog +6 -1
  2. data/src/narray.c +9 -3
  3. data/src/narray.h +2 -2
  4. 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 = total_bak * shape[i];
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
@@ -23,8 +23,8 @@
23
23
  # include <sys/types.h>
24
24
  #endif
25
25
 
26
- #define NARRAY_VERSION "0.6.0.0"
27
- #define NARRAY_VERSION_CODE 600
26
+ #define NARRAY_VERSION "0.6.0.1"
27
+ #define NARRAY_VERSION_CODE 601
28
28
 
29
29
  /*
30
30
  Data types used in NArray :
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: narray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.0
4
+ version: 0.6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Tanaka