Skip to content

Run-Time Check Failure #2 - Stack around the variable 'files' was corrupted. #458

@circusjoker06

Description

@circusjoker06
int main(){
  Json::Reader reader;
  try
  {
    Json::Value root;

    const char* str2 = "{\"uploadid\": \"UP000000\",\"code\":-2105368552146909364,\"msg\": \"\",\"files\":[]}";

    if (reader.parse(str2, root))

    {

      string upload_id = root["uploadid"].asString();

      //int code = root["code"].asInt();

      string code =root["code"].asString();
      string msg = root["msg"].asString();
      Json::Value files =root["files"];
      {
        cout<<"files empty"<<endl;
      }
      cout<<root.size()<<" "<<upload_id<<" "<<code<<" "<<msg<<endl;
    }

  }
  catch(std::exception e)
  {
    // (1) it will catch the error show show
    cerr << e.what() << endl;
  }
  catch(std::out_of_range e)
  {
    // (2) this will also catch the same error if (1) was not there but could
    // get you more details if you wanted since its more specific but i have
    // not digged into it further
    cerr << e.what() << endl;
  }
  catch(...)
  {
    // (3) just for sanity check if first two didn't catch it
    cerr << "something went wrong";
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions