Skip to content

Fix endless loop bug #979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/util/irep_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Date: May 2007

#include "string_hash.h"

irep_serialization_errort::irep_serialization_errort(const std::string &error):
std::runtime_error(error)
{
}

void irep_serializationt::write_irep(
std::ostream &out,
const irept &irep)
Expand Down Expand Up @@ -225,11 +230,17 @@ void write_gb_string(std::ostream &out, const std::string &s)
/// \return a string
irep_idt irep_serializationt::read_gb_string(std::istream &in)
{
char c;
char c='\0';
size_t length=0;

while((c=static_cast<char>(in.get()))!=0)
{
if(!in.good())
{
throw irep_serialization_errort(
"found non-null-terminated string while parsing input");
}

if(length>=read_buffer.size())
read_buffer.resize(read_buffer.size()*2, 0);

Expand Down
6 changes: 6 additions & 0 deletions src/util/irep_serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Date: May 2007
#include "irep_hash_container.h"
#include "irep.h"

class irep_serialization_errort:public std::runtime_error
{
public:
explicit irep_serialization_errort(const std::string &error);
};

void write_gb_word(std::ostream &, std::size_t);
void write_gb_string(std::ostream &, const std::string &);

Expand Down