Following program illustrates the issue (OK with 2.1):-
#include <stdlib.h> #include <stdio.h> struct xfs_fs { char **inode_table; }; /* ------------------------------------------------------------------------ */ static int alloc_xfs(struct xfs_fs *xfs) { int result = 0; char **new_table = malloc(4096 * sizeof(new_table[0])); if (new_table != NULL) { xfs->inode_table = new_table; result = 1; } return result; } /* ------------------------------------------------------------------------ */ int main() { struct xfs_fs *xfs = malloc(sizeof(struct xfs_fs)); xfs->inode_table = 0; if (alloc_xfs(xfs)) { xfs->inode_table[0] = NULL; xfs->inode_table[1] = "entry 1"; xfs->inode_table[2] = "entry 2"; printf("Succeeded!\n"); } }
cppcheck 2.2 complains about the allocations to xfs->inode_table.
xfs->inode_table
Unless I'm missing something obvious, alloc_xfs() only returns non-zero when the assignments to xfs_inode_table are allowed.
alloc_xfs()
xfs_inode_table
The Z3 version incidentally is 4.4.1. I don't know if this makes a difference or not.
Sorry to be pushy, but could I bump this?
This is distilled from a source file on the XRDP project [github.com] which I help to maintain.
Many thanks.
Log in to post a comment.
Following program illustrates the issue (OK with 2.1):-
cppcheck 2.2 complains about the allocations to
xfs->inode_table
.Unless I'm missing something obvious,
alloc_xfs()
only returns non-zero when the assignments toxfs_inode_table
are allowed.The Z3 version incidentally is 4.4.1. I don't know if this makes a difference or not.
Sorry to be pushy, but could I bump this?
This is distilled from a source file on the XRDP project [github.com] which I help to maintain.
Many thanks.