Skip to content

Commit

Permalink
Merge pull request BVLC#8 from BVLC/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
bittnt committed May 8, 2016
2 parents 4bea310 + 14dc012 commit fb2305e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/caffe/blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ void Blob<Dtype>::Reshape(const vector<int>& shape) {
int* shape_data = static_cast<int*>(shape_data_->mutable_cpu_data());
for (int i = 0; i < shape.size(); ++i) {
CHECK_GE(shape[i], 0);
CHECK_LE(shape[i], INT_MAX / count_) << "blob size exceeds INT_MAX";
if (count_ != 0) {
CHECK_LE(shape[i], INT_MAX / count_) << "blob size exceeds INT_MAX";
}
count_ *= shape[i];
shape_[i] = shape[i];
shape_data[i] = shape[i];
Expand Down
8 changes: 8 additions & 0 deletions src/caffe/test/test_blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ TYPED_TEST(BlobSimpleTest, TestReshape) {
EXPECT_EQ(this->blob_->count(), 120);
}

TYPED_TEST(BlobSimpleTest, TestReshapeZero) {
vector<int> shape(2);
shape[0] = 0;
shape[1] = 5;
this->blob_->Reshape(shape);
EXPECT_EQ(this->blob_->count(), 0);
}

TYPED_TEST(BlobSimpleTest, TestLegacyBlobProtoShapeEquals) {
BlobProto blob_proto;

Expand Down

0 comments on commit fb2305e

Please sign in to comment.