Comments (3)
Hi @rvxfahim, your code snippet is not enough to evaluate the correctness of the reported defect. Please attach here a minimal PlatformIO project to reproduce the issue.
from platformio-core.
Hi @rvxfahim, your code snippet is not enough to evaluate the correctness of the reported defect. Please attach here a minimal PlatformIO project to reproduce the issue.
Hi, the code is very big, but the following part is the callback function for a ble characterisitics where this variable is being flagged by the static analysis.
uint8_t ip[4] = {192, 168, 31, 4};
void BLEipCallBack::onWrite(BLECharacteristic *pCharacteristic)
{
std::string value = pCharacteristic->getValue();
// parse the string to get the IP address
// the string is in the format "xxx.xxx.xxx.xxx"
// where x is a number
// the IP address is stored in the global variable ip
ip[4] = {0};
int segmentIndex = 0;
std::string segment = "";
for (char c : value)
{
if (c == '.')
{
ip[segmentIndex] = std::stoi(segment);
segmentIndex++;
segment = "";
}
else
{
segment += c;
}
}
// handle the last segment
ip[segmentIndex] = std::stoi(segment);
// store the blob
NVS.setBlob("ip", ip, sizeof(ip));
// set the IP address
server[0] = ip[0];
server[1] = ip[1];
server[2] = ip[2];
server[3] = ip[3];
nh.getHardware()->setConnection(server, serverPort);
Serial.println("IP address changed to:");
Serial.print(ip[0]);
Serial.print(".");
Serial.print(ip[1]);
Serial.print(".");
Serial.print(ip[2]);
Serial.print(".");
Serial.println(ip[3]);
}
from platformio-core.
You've declared an array of size 4, the array indexing in C/C++ starts from 0, so the lowest index is 0 and the highest index is 3. Executing ip[4]
is an "index out of bounds error" which is correctly reported by Cppcheck.
from platformio-core.
Related Issues (20)
- Bad CPU type in executable clang-tidy on Apple M3 Pro HOT 5
- mbed framework is incompatible with pyelftools-0.30 which is installed by pio HOT 4
- Help
- custom boards_dir not recognized with core version >6.1.11 HOT 1
- LDF can't work with latest Adafruit TinyUSB on any setting HOT 1
- Feature request to support python extra_scripts with dependency manager HOT 3
- Remote Upload and Monitor not using environment config
- Automatically add all generic boards for STM32 (bare chip variants, which are a lot) HOT 1
- Publish IDE to https://open-vsx.org HOT 1
- Problems with –project-dir option to pio init HOT 5
- Library Dependency Finder (LDF) adds too many files when testing (pio test) HOT 2
- Add support for LuatOS ESP32C3-CORE Development Board
- Feature request for support for Milk-V Boards HOT 1
- Feature Request: Support RealTek Ameba AMB82-Mini board (RTL8735BDM) HOT 1
- In the results of the test, different file names are displayed. HOT 3
- NameError: name 'includes' is not defined while updating metadata for VSCode IDE HOT 10
- LDF that picks wrong library version. HOT 2
- Can't build firmware on command line if I specify other targets HOT 2
- Add Sparkfun Thing Plus Matter - MGM240P support HOT 4
- Feature request for support resuming downloads
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from platformio-core.