It overlaps the one that's declared outside of the loop. That's right, another such variable is declared inside the for loop. I intentionally highlighted the line triggered the warning with an arrow, as this function contains more than one string definition with the name pKey. The analyzer warns about the created but not used variable pKey, but in reality, the problem was more interesting. Std::string pKey(edEntityEl->Value()) // GetText() Įdentity.scriptname = std::string(edEntityEl->GetText()) ĮdEntityEl->QueryIntAttribute("x", &edentity.x) ĮdEntityEl->QueryIntAttribute("y", &edentity.y) ĮdEntityEl->QueryIntAttribute("t", &edentity.t) ĮdEntityEl->QueryIntAttribute("p1", &edentity.p1) ĮdEntityEl->QueryIntAttribute("p2", &edentity.p2) ĮdEntityEl->QueryIntAttribute("p3", &edentity.p3) ĮdEntityEl->QueryIntAttribute("p4", &edentity.p4) ĮdEntityEl->QueryIntAttribute("p5", &edentity.p5) ĮdEntityEl->QueryIntAttribute("p6", &edentity.p6) ĮditorData::GetInstance().numedentities = i Tmap = warplevel.loadlevel(rx, ry, game, obj) įor (TiXmlElement *edEntityEl = pElem->FirstChildElement() ĮdEntityEl = edEntityEl->NextSiblingElement()) V519 The 'background' variable is assigned values twice successively. What data in RAM can be damaged and what result it will lead to is a matter of rhetorical question :) What happens if the length of the oldDirectory string is more than 251? The resulting string will be longer than fileSearch could contain, which will lead to violating the array bounds. It is this sequence of characters that will be written in fileSearch. This line is 9 characters longer than the original value of oldDirectory. After writing the contents of the oldDirectory string in the format string (the third sprintf argument), it will look like: contents_oldDirectory\*.vvvvvv Sprintf(fileSearch, "%s\\*.vvvvvv", oldDirectory) Īs you can see, the strings fileSearch and oldDirectory are of the same size: 260 characters. Void PLATFORM_migrateSaveData(char *output) FileSystemUtils.cpp 307 #define MAX_PATH 260 V512 A call of the 'sprintf' function will lead to overflow of the buffer 'fileSearch'. Point the gravity vector down and make yourself comfortable - we're just about to start! Overview of analyzer warnings In this article, we'll look at some interesting errors found by the PVS-Studio analyzer in the VVVVVV code, and take a detailed look at these errors. So when I heard about the opening of the VVVVVV source code, I just couldn't get past it. Our readers get engaging articles on programming topics, and we get the opportunity to demonstrate the capabilities of PVS-Studio. For us, one of the best ways to do this is to write articles about checking open source projects. In addition to directly developing, we are also engaged in our product promotion. After all, every game has its own unique zest :)Īnyway, let's go back to the source code, posted in honor of the game's anniversary.Īt the moment, I'm a developer of the PVS-Studio, which is a static code analyzer for C, C++, C#, and Java. I have no idea how many times my character died then, but I'm sure the number of deaths is measured in the tens of hundreds. Eventually, I completely beat the game despite some challenges, like high complexity with skillfully applied game control, for instance - the main character can't jump, but is able to invert the direction of the gravity vector on himself. As soon as I got out of the starting location, I found myself in a small but confusing and florid two-dimensional world full of unusual landscapes and pixel artifacts unknown to me. I didn't know what was waiting for me at the time. I remember my first impressions: "Is that all? Just running around the square rooms?" I thought after a few minutes of playing. I remember coming across it shortly after the release and being a big fan of pixel retro games, I was so excited to install it on my computer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |