units-2.21-5.fc37
List of Defects
Error: CPPCHECK_WARNING: [#def1]
units-2.21/getopt.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.
Error: CPPCHECK_WARNING: [#def2]
units-2.21/parse.tab.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.
Error: GCC_ANALYZER_WARNING (CWE-457): [#def3]
units-2.21/parse.tab.c: scope_hint: In function ‘unitsparse’
units-2.21/parse.tab.c:600:7: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘yyss’
units-2.21/parse.tab.c:585:9: note: in expansion of macro ‘YYCOPY’
units-2.21/parse.tab.c:1445:9: note: in expansion of macro ‘YYSTACK_RELOCATE’
units-2.21/parse.y:534:7: note: in expansion of macro ‘yyparse’
units-2.21/parse.tab.c:1312:1: note: in expansion of macro ‘yyparse’
units-2.21/parse.tab.c:585:9: note: in expansion of macro ‘YYCOPY’
units-2.21/parse.tab.c:1445:9: note: in expansion of macro ‘YYSTACK_RELOCATE’
units-2.21/parse.tab.c:585:9: note: in expansion of macro ‘YYCOPY’
units-2.21/parse.tab.c:1445:9: note: in expansion of macro ‘YYSTACK_RELOCATE’
# 598| # if defined __GNUC__ && 1 < __GNUC__
# 599| # define YYCOPY(Dst, Src, Count) \
# 600|-> __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
# 601| # else
# 602| # define YYCOPY(Dst, Src, Count) \
Error: CPPCHECK_WARNING: [#def4]
units-2.21/units.c: information[normalCheckLevelMaxBranches]: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.
Error: GCC_ANALYZER_WARNING (CWE-401): [#def5]
units-2.21/units.c: scope_hint: In function ‘growbuffer’
units-2.21/units.c:382:10: warning[-Wanalyzer-malloc-leak]: leak of ‘buffer’
# 380| *bufsize += BUFGROW;
# 381| if (usemalloc)
# 382|-> *buf = malloc(*bufsize);
# 383| else
# 384| *buf = realloc(*buf,*bufsize);
Error: GCC_ANALYZER_WARNING (CWE-401): [#def6]
units-2.21/units.c:384:10: warning[-Wanalyzer-malloc-leak]: leak of ‘buffer’
# 382| *buf = malloc(*bufsize);
# 383| else
# 384|-> *buf = realloc(*buf,*bufsize);
# 385| if (!*buf){
# 386| fprintf(stderr, "%s: memory allocation error (growbuffer)\n",progname);
Error: COMPILER_WARNING (CWE-563): [#def7]
units-2.21/units.c: scope_hint: In function ‘openfile’
units-2.21/units.c:396:7: warning[-Wunused-variable]: unused variable ‘ret’
# 396 | int ret;
# | ^~~
# 394| {
# 395| FILE *fileptr;
# 396|-> int ret;
# 397|
# 398| struct stat statbuf;
Error: CLANG_WARNING: [#def8]
units-2.21/units.c:499:8: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 'string')
# 497| replacectrlchars(char *string)
# 498| {
# 499|-> for(;*string;string++)
# 500| if (iscntrl(*string))
# 501| *string = ' ';
Error: CLANG_WARNING: [#def9]
units-2.21/units.c:515:3: warning[core.uninitialized.Assign]: The expression is an uninitialized value. The computed value will also be garbage
# 513| if (!fgets(buf,size,file))
# 514| return 0;
# 515|-> (*count)++;
# 516| while(strlen(buf)>=2 && 0==strcmp(buf+strlen(buf)-2,"\\\n")){
# 517| (*count)++;
Error: CPPCHECK_WARNING (CWE-476): [#def10]
units-2.21/units.c:621: error[nullPointer]: Null pointer dereference
# 619| len = strlen(str)+1;
# 620| widestr = mymalloc(sizeof(wchar_t)*len, "(strwidth)");
# 621|-> len = mbsrtowcs(widestr, &str, len, NULL);
# 622|
# 623| if (len==-1){
Error: COMPILER_WARNING (CWE-563): [#def11]
units-2.21/units.c: scope_hint: In function ‘readunits’
units-2.21/units.c:804:41: warning[-Wunused-value]: value computed is not used
# 804 | #define readerror (goterr=1) && errfile && fprintf
# | ^~
units-2.21/units.c:1645:9: note: in expansion of macro ‘readerror’
# 1645 | readerror(errfile, "%s: %s on line %d of '%s'\n",
# | ^~~~~~~~~
# 802|
# 803|
# 804|-> #define readerror (goterr=1) && errfile && fprintf
# 805|
# 806| #define VAGUE_ERR "%s: error in units file '%s' line %d\n", \
Error: CLANG_WARNING: [#def12]
units-2.21/units.c:1227:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'domain_min'
# 1225| if (i==FN_UNITS){
# 1226| if (forward_dim || inverse_dim){
# 1227|-> REPEAT_ERR;
# 1228| return E_BADFILE;
# 1229| }
Error: CLANG_WARNING: [#def13]
units-2.21/units.c:1227:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'forward_dim'
# 1225| if (i==FN_UNITS){
# 1226| if (forward_dim || inverse_dim){
# 1227|-> REPEAT_ERR;
# 1228| return E_BADFILE;
# 1229| }
Error: CLANG_WARNING: [#def14]
units-2.21/units.c:1227:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'inverse_dim'
# 1225| if (i==FN_UNITS){
# 1226| if (forward_dim || inverse_dim){
# 1227|-> REPEAT_ERR;
# 1228| return E_BADFILE;
# 1229| }
Error: CLANG_WARNING: [#def15]
units-2.21/units.c:1230:25: warning[core.CallAndMessage]: 1st function call argument is an uninitialized value
# 1228| return E_BADFILE;
# 1229| }
# 1230|-> forward_dim = dupstr(first);
# 1231| if (second)
# 1232| inverse_dim = dupstr(second);
Error: CLANG_WARNING: [#def16]
units-2.21/units.c:1240:17: warning[core.CallAndMessage]: 1st function call argument is an uninitialized value
# 1238| return E_BADFILE;
# 1239| }
# 1240|-> err = extract_interval(first,second,&domain_min, &domain_max);
# 1241| domain_min_open = firstopen;
# 1242| domain_max_open = secondopen;
Error: CLANG_WARNING: [#def17]
units-2.21/units.c:1265:17: warning[core.CallAndMessage]: 1st function call argument is an uninitialized value
# 1263| return E_BADFILE;
# 1264| }
# 1265|-> err = extract_interval(first,second,&range_min, &range_max);
# 1266| range_min_open = firstopen;
# 1267| range_max_open = secondopen;
Error: CPPCHECK_WARNING (CWE-401): [#def18]
units-2.21/units.c:1408: error[memleakOnRealloc]: Common realloc mistake: 'tab' nulled but not freed upon failure
# 1406| if (tabpt>=tablealloc){
# 1407| tablealloc+=20;
# 1408|-> tab = (struct pair *)realloc(tab,sizeof(struct pair)*tablealloc);
# 1409| if (!tab){
# 1410| if (errfile) fprintf(errfile, "%s: memory allocation error (newtable)\n",
Error: CLANG_WARNING: [#def19]
units-2.21/units.c:1876:4: warning[unix.Malloc]: Potential leak of memory pointed to by 'permfile'
# 1874| }
# 1875| }
# 1876|-> fclose(unitfile);
# 1877| free(line);
# 1878| if (unitcount)
Error: CPPCHECK_WARNING (CWE-476): [#def20]
units-2.21/units.c:2376: error[ctunullpointer]: Null pointer dereference: first
# 2374| {
# 2375| return
# 2376|-> compareproducts(first->numerator, second->numerator, isdimless) ||
# 2377| compareproducts(first->denominator, second->denominator, isdimless);
# 2378| }
Error: GCC_ANALYZER_WARNING (CWE-457): [#def21]
units-2.21/units.c: scope_hint: In function ‘showfunction’
units-2.21/units.c:2832:23: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘not_dimensionless’
# 2830| if (func->domain_min && func->domain_max) {
# 2831| logprintf(num_format.format, *func->domain_min);
# 2832|-> if (func->dimen && (not_dimensionless || unit.factor != 1)){
# 2833| if (isdecimal(*func->dimen))
# 2834| logputs(" *");
Error: GCC_ANALYZER_WARNING (CWE-457): [#def22]
units-2.21/units.c:2857:8: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘not_dimensionless’
# 2855| logputchar('\n');
# 2856| for(i=strwidth(deftext);i;i--) logputchar(' ');
# 2857|-> if (not_dimensionless)
# 2858| logprintf("%s has units %s",func->param, func->dimen);
# 2859| else
Error: COMPILER_WARNING (CWE-457): [#def23]
units-2.21/units.c: scope_hint: In function ‘showfunction’
units-2.21/units.c:2857:8: warning[-Wmaybe-uninitialized]: ‘not_dimensionless’ may be used uninitialized
# 2857 | if (not_dimensionless)
# | ^
units-2.21/units.c:2813:7: note: ‘not_dimensionless’ was declared here
# 2813 | int not_dimensionless, i;
# | ^~~~~~~~~~~~~~~~~
# 2855| logputchar('\n');
# 2856| for(i=strwidth(deftext);i;i--) logputchar(' ');
# 2857|-> if (not_dimensionless)
# 2858| logprintf("%s has units %s",func->param, func->dimen);
# 2859| else
Error: CPPCHECK_WARNING (CWE-457): [#def24]
units-2.21/units.c:3681: error[legacyUninitvar]: Uninitialized variable: indent
# 3679| if (errors[i]) {
# 3680| lastchar(unittext) = '0'+i;
# 3681|-> printf("%s%s(",indent,infunc->name);
# 3682| printf(num_format.format, factor);
# 3683| printf("%s): %s\n", unittext, errormsg[errors[i]]);
Error: CLANG_WARNING: [#def25]
units-2.21/units.c:4052:13: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 'curbuiltin')
# 4050| }
# 4051| if (checktype == CU_BUILTIN){
# 4052|-> while(*curbuiltin){
# 4053| if (startswith(*curbuiltin,text))
# 4054| output = dupstr(*curbuiltin);
Error: COMPILER_WARNING (CWE-563): [#def26]
units-2.21/units.c: scope_hint: In function ‘checkcwd’
units-2.21/units.c:4131:9: warning[-Wunused-variable]: unused variable ‘p’
# 4131 | char *p;
# | ^
# 4129| {
# 4130| FILE *fp;
# 4131|-> char *p;
# 4132|
# 4133| fp = openfile(file, "r");
Error: GCC_ANALYZER_WARNING (CWE-401): [#def27]
units-2.21/units.c: scope_hint: In function ‘getprogdir’
units-2.21/units.c:4279:10: warning[-Wanalyzer-malloc-leak]: leak of ‘progdir’
# 4277| *p = '\0';
# 4278|
# 4279|-> return progdir;
# 4280| }
# 4281|
Error: CPPCHECK_WARNING (CWE-672): [#def28]
units-2.21/units.c:4536: error[deallocret]: Returning/dereferencing 'file' after it is deallocated / released
# 4534| else {
# 4535| fclose(testfile);
# 4536|-> return file;
# 4537| }
# 4538| }
Error: COMPILER_WARNING (CWE-563): [#def29]
units-2.21/units.c: scope_hint: In function ‘printversion’
units-2.21/units.c:4749:9: warning[-Wunused-variable]: unused variable ‘fp’
# 4749 | FILE *fp, *histfile;
# | ^~
# 4747| char *m_unitsfile; /* personal units data file from HOME_UNITS_ENV */
# 4748| char *p_unitsfile; /* personal units data file */
# 4749|-> FILE *fp, *histfile;
# 4750| #ifdef _WIN32
# 4751| char *localemap;
Error: CLANG_WARNING: [#def30]
units-2.21/units.c:4826:13: warning[unix.Malloc]: Potential leak of memory pointed to by 'p_unitsfile'
# 4824| printf("Personal units data file is '%s'\n", p_unitsfile);
# 4825| if (!exists){
# 4826|-> if (homedir_error && !nonempty(m_unitsfile))
# 4827| printf(" (File invalid: %s)\n", homedir_error);
# 4828| else if (errno==ENOENT && !nonempty(m_unitsfile))
Error: CLANG_WARNING: [#def31]
units-2.21/units.c:5136:26: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
# 5134| char savechar;
# 5135|
# 5136|-> if (flags.unitlists && strchr(unitstr, UNITSEPCHAR)){
# 5137| puts("Unit list not allowed");
# 5138| return 1;
Error: CPPCHECK_WARNING (CWE-476): [#def32]
units-2.21/units.c:5558: warning[nullPointer]: Possible null pointer dereference: lastunitstr
# 5556| if (!value_shown) { /* provide output if every value rounded to zero */
# 5557| logputs("0 ");
# 5558|-> if (isdecimal(*lastunitstr))
# 5559| logputs("* ");
# 5560| logputs(lastunitstr);
Error: CLANG_WARNING: [#def33]
units-2.21/units.c:5558:19: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 'lastunitstr')
# 5556| if (!value_shown) { /* provide output if every value rounded to zero */
# 5557| logputs("0 ");
# 5558|-> if (isdecimal(*lastunitstr))
# 5559| logputs("* ");
# 5560| logputs(lastunitstr);
Scan Properties
analyzer-version-clang | 17.0.6 |
analyzer-version-cppcheck | 2.14.2 |
analyzer-version-gcc | 13.3.1 |
analyzer-version-gcc-analyzer | 13.3.1 |
analyzer-version-shellcheck | 0.9.0 |
enabled-plugins | clang, cppcheck, gcc, shellcheck |
exit-code | 0 |
host | ip-172-16-1-218.us-west-2.compute.internal |
mock-config | fedora-39-x86_64 |
project-name | units-2.21-5.fc37 |
store-results-to | /tmp/tmpv2up_zji/units-2.21-5.fc37.tar.xz |
time-created | 2024-07-03 11:43:53 |
time-finished | 2024-07-03 11:46:41 |
tool | csmock |
tool-args | '/usr/bin/csmock' '-r' 'fedora-39-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmpv2up_zji/units-2.21-5.fc37.tar.xz' '--gcc-analyze' '/tmp/tmpv2up_zji/units-2.21-5.fc37.src.rpm' |
tool-version | csmock-3.5.3-1.el9 |