Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline static int *alloc(void * pvApiCtx, const int position,
- const int rows, const int cols, int * ptr)
- {
- int * _ptr = 0;
- SciErr err = allocMatrixOfInteger32(
- pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
- return _ptr;
- }
- inline static void create(void * pvApiCtx, const int position,
- const int rows, const int cols, long long * ptr)
- {
- int * dataPtr = 0;
- alloc(pvApiCtx, position, rows, cols, dataPtr);
- for (int i = 0; i < rows * cols; i++)
- {
- dataPtr[i] = static_cast<int>(ptr[i]);
- }
- }
- This is what should have been written here: dataPtr = alloc(pvApiCtx, position, rows, cols, dataPtr);
- This suspicious code was found in Scilab project by PVS-Studio static code analyzer.
- Warning message is:
- V522 Dereferencing of the null pointer 'dataPtr' might take place. scilababstractmemoryallocator.hxx 222
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment