Skip to content

Commit

Permalink
Increase size limits.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkestene committed Apr 25, 2024
1 parent 84eabe4 commit 37d8ad2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/cnpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <iomanip>
#include <stdint.h>
#include <stdexcept>
#include <sstream>
#include <regex>

char
Expand Down Expand Up @@ -116,7 +117,10 @@ cnpy::parse_npy_header(unsigned char * buffer,
std::string str_shape = header.substr(loc1 + 1, loc2 - loc1 - 1);
while (std::regex_search(str_shape, sm, num_regex))
{
shape.push_back(std::stoi(sm[0].str()));
std::stringstream stream(sm[0].str());
size_t size;
stream >> size;
shape.push_back(size);
str_shape = sm.suffix().str();
}

Expand Down Expand Up @@ -170,7 +174,11 @@ cnpy::parse_npy_header(FILE * fp,
std::string str_shape = header.substr(loc1 + 1, loc2 - loc1 - 1);
while (std::regex_search(str_shape, sm, num_regex))
{
shape.push_back(std::stoi(sm[0].str()));
std::stringstream stream(sm[0].str());
size_t size;
stream >> size;

shape.push_back(size);
str_shape = sm.suffix().str();
}

Expand Down

0 comments on commit 37d8ad2

Please sign in to comment.