libmtp-1.1.22-1.fc44

List of Findings

Error: GCC_ANALYZER_WARNING (CWE-401): [#def1]
libmtp-1.1.22/examples/albumart.c:67:7: warning[-Wanalyzer-malloc-leak]: leak of ‘albumname’
libmtp-1.1.22/examples/albumart.c:62:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/albumart.c:63:5: branch_true: ...to here
libmtp-1.1.22/examples/albumart.c:79:19: acquire_memory: allocated here
libmtp-1.1.22/examples/albumart.c:62:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/albumart.c:63:5: branch_true: ...to here
libmtp-1.1.22/examples/albumart.c:67:7: throw: if ‘LIBMTP_Set_Debug’ throws an exception...
libmtp-1.1.22/examples/albumart.c:67:7: danger: ‘albumname’ leaks here; was allocated at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)
#   65|         usage();
#   66|       case 'd':
#   67|->       LIBMTP_Set_Debug(LIBMTP_DEBUG_PTP | LIBMTP_DEBUG_DATA);
#   68|         break;
#   69|       case 'i':

Error: GCC_ANALYZER_WARNING (CWE-401): [#def2]
libmtp-1.1.22/examples/newplaylist.c:90:3: warning[-Wanalyzer-malloc-leak]: leak of ‘ids’
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: following ‘false’ branch (when ‘playlistname’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: following ‘false’ branch (when ‘idcount != 0’)...
libmtp-1.1.22/examples/newplaylist.c:90:3: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:90:3: throw: if ‘LIBMTP_Init’ throws an exception...
libmtp-1.1.22/examples/newplaylist.c:90:3: danger: ‘ids’ leaks here; was allocated at [(12)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/11)
#   88|   
#   89|       
#   90|->   LIBMTP_Init();
#   91|     device = LIBMTP_Get_First_Device();
#   92|     if (device == NULL) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def3]
libmtp-1.1.22/examples/newplaylist.c:90:3: warning[-Wanalyzer-malloc-leak]: leak of ‘playlistname’
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:64:22: acquire_memory: allocated here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: following ‘false’ branch (when ‘playlistname’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: following ‘false’ branch (when ‘idcount != 0’)...
libmtp-1.1.22/examples/newplaylist.c:90:3: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:90:3: throw: if ‘LIBMTP_Init’ throws an exception...
libmtp-1.1.22/examples/newplaylist.c:90:3: danger: ‘playlistname’ leaks here; was allocated at [(19)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/18)
#   88|   
#   89|       
#   90|->   LIBMTP_Init();
#   91|     device = LIBMTP_Get_First_Device();
#   92|     if (device == NULL) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def4]
libmtp-1.1.22/examples/newplaylist.c:91:12: warning[-Wanalyzer-malloc-leak]: leak of ‘ids’
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: following ‘false’ branch (when ‘playlistname’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: following ‘false’ branch (when ‘idcount != 0’)...
libmtp-1.1.22/examples/newplaylist.c:90:3: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:91:12: throw: if ‘LIBMTP_Get_First_Device’ throws an exception...
libmtp-1.1.22/examples/newplaylist.c:91:12: danger: ‘ids’ leaks here; was allocated at [(12)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/11)
#   89|       
#   90|     LIBMTP_Init();
#   91|->   device = LIBMTP_Get_First_Device();
#   92|     if (device == NULL) {
#   93|       printf("No devices.\n");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def5]
libmtp-1.1.22/examples/newplaylist.c:91:12: warning[-Wanalyzer-malloc-leak]: leak of ‘playlistname’
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:64:22: acquire_memory: allocated here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: following ‘false’ branch (when ‘playlistname’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: following ‘false’ branch (when ‘idcount != 0’)...
libmtp-1.1.22/examples/newplaylist.c:90:3: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:91:12: throw: if ‘LIBMTP_Get_First_Device’ throws an exception...
libmtp-1.1.22/examples/newplaylist.c:91:12: danger: ‘playlistname’ leaks here; was allocated at [(19)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/18)
#   89|       
#   90|     LIBMTP_Init();
#   91|->   device = LIBMTP_Get_First_Device();
#   92|     if (device == NULL) {
#   93|       printf("No devices.\n");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def6]
libmtp-1.1.22/examples/newplaylist.c:97:33: warning[-Wanalyzer-malloc-leak]: leak of ‘ids’
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: following ‘false’ branch (when ‘playlistname’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: following ‘false’ branch (when ‘idcount != 0’)...
libmtp-1.1.22/examples/newplaylist.c:90:3: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:92:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/newplaylist.c:97:33: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:97:33: throw: if ‘LIBMTP_new_playlist_t’ throws an exception...
libmtp-1.1.22/examples/newplaylist.c:97:33: danger: ‘ids’ leaks here; was allocated at [(12)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/11)
#   95|     }
#   96|   
#   97|->   LIBMTP_playlist_t *playlist = LIBMTP_new_playlist_t();
#   98|     playlist->name = playlistname;
#   99|     playlist->no_tracks = idcount;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def7]
libmtp-1.1.22/examples/newplaylist.c:97:33: warning[-Wanalyzer-malloc-leak]: leak of ‘playlistname’
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:56:10: branch_false: following ‘false’ branch (when ‘tmp’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:61:26: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/newplaylist.c:51:5: branch_true: ...to here
libmtp-1.1.22/examples/newplaylist.c:64:22: acquire_memory: allocated here
libmtp-1.1.22/examples/newplaylist.c:50:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:79:6: branch_false: following ‘false’ branch (when ‘playlistname’ is non-NULL)...
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:84:6: branch_false: following ‘false’ branch (when ‘idcount != 0’)...
libmtp-1.1.22/examples/newplaylist.c:90:3: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:92:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/newplaylist.c:97:33: branch_false: ...to here
libmtp-1.1.22/examples/newplaylist.c:97:33: throw: if ‘LIBMTP_new_playlist_t’ throws an exception...
libmtp-1.1.22/examples/newplaylist.c:97:33: danger: ‘playlistname’ leaks here; was allocated at [(19)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/18)
#   95|     }
#   96|   
#   97|->   LIBMTP_playlist_t *playlist = LIBMTP_new_playlist_t();
#   98|     playlist->name = playlistname;
#   99|     playlist->no_tracks = idcount;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def8]
libmtp-1.1.22/examples/pathutils.c:45:3: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘current’ where non-null expected
libmtp-1.1.22/examples/pathutils.c:37:6: branch_false: following ‘false’ branch (when the strings are non-equal)...
libmtp-1.1.22/examples/pathutils.c:40:6: branch_false: ...to here
libmtp-1.1.22/examples/pathutils.c:40:6: branch_false: following ‘false’ branch (when ‘folder’ is non-NULL)...
libmtp-1.1.22/examples/pathutils.c:44:21: branch_false: ...to here
libmtp-1.1.22/examples/pathutils.c:44:13: acquire_memory: this call could return NULL
libmtp-1.1.22/examples/pathutils.c:45:3: danger: argument 1 (‘current’) from [(5)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/4) could be NULL where non-null expected
#   43|   
#   44|     current = malloc (strlen(parent) + strlen(folder->name) + 2);
#   45|->   sprintf(current,"%s/%s",parent,folder->name);
#   46|     if (strcasecmp (path, current) == 0) {
#   47|       free (current);

Error: COMPILER_WARNING: [#def9]
libmtp-1.1.22/examples/pathutils.c: scope_hint: In function ‘progress’
libmtp-1.1.22/examples/pathutils.c:122:24: warning[-Wformat=]: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’}
#  122 |   printf("Progress: %llu of %llu (%d%%)\r", sent, total, percent);
#      |                     ~~~^                    ~~~~
#      |                        |                    |
#      |                        |                    uint64_t {aka long unsigned int}
#      |                        long long unsigned int
#      |                     %lu
#  120|     printf("Progress: %I64u of %I64u (%d%%)\r", sent, total, percent);
#  121|   #else
#  122|->   printf("Progress: %llu of %llu (%d%%)\r", sent, total, percent);
#  123|   #endif
#  124|     fflush(stdout);

Error: COMPILER_WARNING: [#def10]
libmtp-1.1.22/examples/pathutils.c:122:32: warning[-Wformat=]: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long unsigned int’}
#  122 |   printf("Progress: %llu of %llu (%d%%)\r", sent, total, percent);
#      |                             ~~~^                  ~~~~~
#      |                                |                  |
#      |                                |                  uint64_t {aka long unsigned int}
#      |                                long long unsigned int
#      |                             %lu
#  120|     printf("Progress: %I64u of %I64u (%d%%)\r", sent, total, percent);
#  121|   #else
#  122|->   printf("Progress: %llu of %llu (%d%%)\r", sent, total, percent);
#  123|   #endif
#  124|     fflush(stdout);

Error: CPPCHECK_WARNING (CWE-476): [#def11]
libmtp-1.1.22/examples/sendtr.c:155: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: trackid
#  153|   
#  154|       trackid = (uint32_t *)malloc(sizeof(uint32_t));
#  155|->     *trackid = trackmeta->item_id;
#  156|       albuminfo->tracks = trackid;
#  157|       albuminfo->no_tracks = 1;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def12]
libmtp-1.1.22/examples/sendtr.c:463:5: warning[-Wanalyzer-malloc-leak]: leak of ‘palbumartist’
libmtp-1.1.22/examples/sendtr.c:406:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/sendtr.c:407:5: branch_true: ...to here
libmtp-1.1.22/examples/sendtr.c:418:22: acquire_memory: allocated here
libmtp-1.1.22/examples/sendtr.c:458:6: branch_false: following ‘false’ branch (when ‘argc == 2’)...
libmtp-1.1.22/examples/sendtr.c:463:5: branch_false: ...to here
libmtp-1.1.22/examples/sendtr.c:463:5: throw: if ‘checklang’ throws an exception...
libmtp-1.1.22/examples/sendtr.c:463:5: danger: ‘palbumartist’ leaks here; was allocated at [(3)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/2)
#  461|       ret = 0;
#  462|     } else {
#  463|->     checklang();
#  464|       printf("%s,%s,%s,%s,%s,%s,%s,%s,%d%d,%d,%u,%d\n",argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer,tracknum, length, year, storageid, quiet);
#  465|       ret = sendtrack_function(argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer, tracknum, length, year, storageid, quiet);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def13]
libmtp-1.1.22/examples/sendtr.c:463:5: warning[-Wanalyzer-malloc-leak]: leak of ‘partist’
libmtp-1.1.22/examples/sendtr.c:406:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/sendtr.c:407:5: branch_true: ...to here
libmtp-1.1.22/examples/sendtr.c:414:17: acquire_memory: allocated here
libmtp-1.1.22/examples/sendtr.c:458:6: branch_false: following ‘false’ branch (when ‘argc == 2’)...
libmtp-1.1.22/examples/sendtr.c:463:5: branch_false: ...to here
libmtp-1.1.22/examples/sendtr.c:463:5: throw: if ‘checklang’ throws an exception...
libmtp-1.1.22/examples/sendtr.c:463:5: danger: ‘partist’ leaks here; was allocated at [(3)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/2)
#  461|       ret = 0;
#  462|     } else {
#  463|->     checklang();
#  464|       printf("%s,%s,%s,%s,%s,%s,%s,%s,%d%d,%d,%u,%d\n",argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer,tracknum, length, year, storageid, quiet);
#  465|       ret = sendtrack_function(argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer, tracknum, length, year, storageid, quiet);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def14]
libmtp-1.1.22/examples/sendtr.c:463:5: warning[-Wanalyzer-malloc-leak]: leak of ‘ptitle’
libmtp-1.1.22/examples/sendtr.c:406:11: branch_true: following ‘true’ branch (when ‘opt != -1’)...
libmtp-1.1.22/examples/sendtr.c:407:5: branch_true: ...to here
libmtp-1.1.22/examples/sendtr.c:410:16: acquire_memory: allocated here
libmtp-1.1.22/examples/sendtr.c:458:6: branch_false: following ‘false’ branch (when ‘argc == 2’)...
libmtp-1.1.22/examples/sendtr.c:463:5: branch_false: ...to here
libmtp-1.1.22/examples/sendtr.c:463:5: throw: if ‘checklang’ throws an exception...
libmtp-1.1.22/examples/sendtr.c:463:5: danger: ‘ptitle’ leaks here; was allocated at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)
#  461|       ret = 0;
#  462|     } else {
#  463|->     checklang();
#  464|       printf("%s,%s,%s,%s,%s,%s,%s,%s,%d%d,%d,%u,%d\n",argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer,tracknum, length, year, storageid, quiet);
#  465|       ret = sendtrack_function(argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer, tracknum, length, year, storageid, quiet);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def15]
libmtp-1.1.22/examples/thumb.c:90:14: warning[-Wanalyzer-malloc-leak]: leak of ‘imagedata’
libmtp-1.1.22/examples/thumb.c:58:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/thumb.c:69:8: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:72:6: branch_false: following ‘false’ branch (when ‘argc == 1’)...
libmtp-1.1.22/examples/thumb.c:77:3: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:79:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:84:14: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:85:15: acquire_memory: allocated here
libmtp-1.1.22/examples/thumb.c:90:14: throw: if ‘open’ throws an exception...
libmtp-1.1.22/examples/thumb.c:90:14: danger: ‘imagedata’ leaks here; was allocated at [(7)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/6)
#   88|     if ( (fd = open(path, O_RDONLY|O_BINARY) == -1) ) {
#   89|   #else
#   90|->   if ( (fd = open(path, O_RDONLY)) == -1) {
#   91|   #endif
#   92|       printf("Couldn't open image file %s (%s)\n",path,strerror(errno));

Error: GCC_ANALYZER_WARNING (CWE-775): [#def16]
libmtp-1.1.22/examples/thumb.c:96:20: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(path, 0)’
libmtp-1.1.22/examples/thumb.c:58:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/thumb.c:69:8: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:72:6: branch_false: following ‘false’ branch (when ‘argc == 1’)...
libmtp-1.1.22/examples/thumb.c:77:3: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:79:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:84:14: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:90:14: acquire_resource: opened here
libmtp-1.1.22/examples/thumb.c:90:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:95:11: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:96:8: branch_true: following ‘true’ branch (when ‘ret == -1’)...
libmtp-1.1.22/examples/thumb.c:96:20: branch_true: ...to here
libmtp-1.1.22/examples/thumb.c:96:20: throw: if ‘perror’ throws an exception...
libmtp-1.1.22/examples/thumb.c:96:20: danger: ‘open(path, 0)’ leaks here; was opened at [(7)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/6)
#   94|     } else {
#   95|       ret = read(fd, imagedata, filesize);
#   96|->     if (ret == -1) perror("read thumb data");
#   97|       close(fd);
#   98|     }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def17]
libmtp-1.1.22/examples/thumb.c:96:20: warning[-Wanalyzer-malloc-leak]: leak of ‘imagedata’
libmtp-1.1.22/examples/thumb.c:58:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/thumb.c:69:8: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:72:6: branch_false: following ‘false’ branch (when ‘argc == 1’)...
libmtp-1.1.22/examples/thumb.c:77:3: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:79:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:84:14: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:85:15: acquire_memory: allocated here
libmtp-1.1.22/examples/thumb.c:90:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:95:11: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:96:8: branch_true: following ‘true’ branch (when ‘ret == -1’)...
libmtp-1.1.22/examples/thumb.c:96:20: branch_true: ...to here
libmtp-1.1.22/examples/thumb.c:96:20: throw: if ‘perror’ throws an exception...
libmtp-1.1.22/examples/thumb.c:96:20: danger: ‘imagedata’ leaks here; was allocated at [(7)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/6)
#   94|     } else {
#   95|       ret = read(fd, imagedata, filesize);
#   96|->     if (ret == -1) perror("read thumb data");
#   97|       close(fd);
#   98|     }

Error: GCC_ANALYZER_WARNING (CWE-775): [#def18]
libmtp-1.1.22/examples/thumb.c:97:5: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(path, 0)’
libmtp-1.1.22/examples/thumb.c:58:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/thumb.c:69:8: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:72:6: branch_false: following ‘false’ branch (when ‘argc == 1’)...
libmtp-1.1.22/examples/thumb.c:77:3: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:79:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:84:14: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:90:14: acquire_resource: opened here
libmtp-1.1.22/examples/thumb.c:90:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:95:11: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:97:5: danger: ‘open(path, 0)’ leaks here; was opened at [(7)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/6)
#   95|       ret = read(fd, imagedata, filesize);
#   96|       if (ret == -1) perror("read thumb data");
#   97|->     close(fd);
#   98|     }
#   99|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def19]
libmtp-1.1.22/examples/thumb.c:97:5: warning[-Wanalyzer-malloc-leak]: leak of ‘imagedata’
libmtp-1.1.22/examples/thumb.c:58:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/thumb.c:69:8: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:72:6: branch_false: following ‘false’ branch (when ‘argc == 1’)...
libmtp-1.1.22/examples/thumb.c:77:3: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:79:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:84:14: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:85:15: acquire_memory: allocated here
libmtp-1.1.22/examples/thumb.c:90:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:95:11: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:97:5: throw: if ‘close’ throws an exception...
libmtp-1.1.22/examples/thumb.c:97:5: danger: ‘imagedata’ leaks here; was allocated at [(7)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/6)
#   95|       ret = read(fd, imagedata, filesize);
#   96|       if (ret == -1) perror("read thumb data");
#   97|->     close(fd);
#   98|     }
#   99|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def20]
libmtp-1.1.22/examples/thumb.c:100:3: warning[-Wanalyzer-malloc-leak]: leak of ‘imagedata’
libmtp-1.1.22/examples/thumb.c:58:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/thumb.c:69:8: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:72:6: branch_false: following ‘false’ branch (when ‘argc == 1’)...
libmtp-1.1.22/examples/thumb.c:77:3: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:79:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:84:14: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:85:15: acquire_memory: allocated here
libmtp-1.1.22/examples/thumb.c:90:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:95:11: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:100:3: throw: if ‘LIBMTP_Init’ throws an exception...
libmtp-1.1.22/examples/thumb.c:100:3: danger: ‘imagedata’ leaks here; was allocated at [(7)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/6)
#   98|     }
#   99|   
#  100|->   LIBMTP_Init();
#  101|     device = LIBMTP_Get_First_Device();
#  102|     if (device == NULL) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def21]
libmtp-1.1.22/examples/thumb.c:101:12: warning[-Wanalyzer-malloc-leak]: leak of ‘imagedata’
libmtp-1.1.22/examples/thumb.c:58:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/thumb.c:69:8: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:72:6: branch_false: following ‘false’ branch (when ‘argc == 1’)...
libmtp-1.1.22/examples/thumb.c:77:3: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:79:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:84:14: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:85:15: acquire_memory: allocated here
libmtp-1.1.22/examples/thumb.c:90:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:95:11: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:101:12: throw: if ‘LIBMTP_Get_First_Device’ throws an exception...
libmtp-1.1.22/examples/thumb.c:101:12: danger: ‘imagedata’ leaks here; was allocated at [(7)](sarif:/runs/0/results/6/codeFlows/0/threadFlows/0/locations/6)
#   99|   
#  100|     LIBMTP_Init();
#  101|->   device = LIBMTP_Get_First_Device();
#  102|     if (device == NULL) {
#  103|       printf("No devices.\n");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def22]
libmtp-1.1.22/examples/thumb.c:107:36: warning[-Wanalyzer-malloc-leak]: leak of ‘imagedata’
libmtp-1.1.22/examples/thumb.c:58:11: branch_false: following ‘false’ branch (when ‘opt == -1’)...
libmtp-1.1.22/examples/thumb.c:69:8: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:72:6: branch_false: following ‘false’ branch (when ‘argc == 1’)...
libmtp-1.1.22/examples/thumb.c:77:3: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:79:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:84:14: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:85:15: acquire_memory: allocated here
libmtp-1.1.22/examples/thumb.c:90:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:95:11: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:102:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/examples/thumb.c:107:36: branch_false: ...to here
libmtp-1.1.22/examples/thumb.c:107:36: throw: if ‘LIBMTP_new_filesampledata_t’ throws an exception...
libmtp-1.1.22/examples/thumb.c:107:36: danger: ‘imagedata’ leaks here; was allocated at [(7)](sarif:/runs/0/results/7/codeFlows/0/threadFlows/0/locations/6)
#  105|     }
#  106|     
#  107|->   LIBMTP_filesampledata_t *thumb = LIBMTP_new_filesampledata_t();
#  108|     thumb->data = imagedata;
#  109|     thumb->size = filesize;

Error: CPPCHECK_WARNING (CWE-476): [#def23]
libmtp-1.1.22/src/libmtp.c:1888: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: extension
# 1886|   
# 1887|               extension = malloc(sizeof(LIBMTP_device_extension_t));
# 1888|->             extension->name = name;
# 1889|               extension->major = major;
# 1890|               extension->minor = minor;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def24]
libmtp-1.1.22/src/libmtp.c:1888:13: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'extension'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1886|   
# 1887|               extension = malloc(sizeof(LIBMTP_device_extension_t));
# 1888|->             extension->name = name;
# 1889|               extension->major = major;
# 1890|               extension->minor = minor;

Error: CPPCHECK_WARNING (CWE-476): [#def25]
libmtp-1.1.22/src/libmtp.c:1889: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: extension
# 1887|               extension = malloc(sizeof(LIBMTP_device_extension_t));
# 1888|               extension->name = name;
# 1889|->             extension->major = major;
# 1890|               extension->minor = minor;
# 1891|               extension->next = NULL;

Error: CPPCHECK_WARNING (CWE-476): [#def26]
libmtp-1.1.22/src/libmtp.c:1890: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: extension
# 1888|               extension->name = name;
# 1889|               extension->major = major;
# 1890|->             extension->minor = minor;
# 1891|               extension->next = NULL;
# 1892|               if (mtpdevice->extensions == NULL) {

Error: CPPCHECK_WARNING (CWE-476): [#def27]
libmtp-1.1.22/src/libmtp.c:1891: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: extension
# 1889|               extension->major = major;
# 1890|               extension->minor = minor;
# 1891|->             extension->next = NULL;
# 1892|               if (mtpdevice->extensions == NULL) {
# 1893|                 mtpdevice->extensions = extension;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def28]
libmtp-1.1.22/src/libmtp.c:1969:39: warning[-Wanalyzer-malloc-leak]: leak of 'current_params'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1967|     current_params->byteorder = PTP_DL_LE;
# 1968|   #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
# 1969|->   current_params->cd_locale_to_ucs2 = iconv_open("UTF-16LE", "UTF-8");
# 1970|     current_params->cd_ucs2_to_locale = iconv_open("UTF-8", "UTF-16LE");
# 1971|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def29]
libmtp-1.1.22/src/libmtp.c:1969:39: warning[-Wanalyzer-malloc-leak]: leak of 'mtp_device'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1967|     current_params->byteorder = PTP_DL_LE;
# 1968|   #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
# 1969|->   current_params->cd_locale_to_ucs2 = iconv_open("UTF-16LE", "UTF-8");
# 1970|     current_params->cd_ucs2_to_locale = iconv_open("UTF-8", "UTF-16LE");
# 1971|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def30]
libmtp-1.1.22/src/libmtp.c:1970:39: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1968|   #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
# 1969|     current_params->cd_locale_to_ucs2 = iconv_open("UTF-16LE", "UTF-8");
# 1970|->   current_params->cd_ucs2_to_locale = iconv_open("UTF-8", "UTF-16LE");
# 1971|   
# 1972|     if(current_params->cd_locale_to_ucs2 == (iconv_t) -1 ||

Error: GCC_ANALYZER_WARNING (CWE-401): [#def31]
libmtp-1.1.22/src/libmtp.c:1970:39: warning[-Wanalyzer-malloc-leak]: leak of 'current_params'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1968|   #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
# 1969|     current_params->cd_locale_to_ucs2 = iconv_open("UTF-16LE", "UTF-8");
# 1970|->   current_params->cd_ucs2_to_locale = iconv_open("UTF-8", "UTF-16LE");
# 1971|   
# 1972|     if(current_params->cd_locale_to_ucs2 == (iconv_t) -1 ||

Error: GCC_ANALYZER_WARNING (CWE-401): [#def32]
libmtp-1.1.22/src/libmtp.c:1970:39: warning[-Wanalyzer-malloc-leak]: leak of 'mtp_device'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1968|   #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
# 1969|     current_params->cd_locale_to_ucs2 = iconv_open("UTF-16LE", "UTF-8");
# 1970|->   current_params->cd_ucs2_to_locale = iconv_open("UTF-8", "UTF-16LE");
# 1971|   
# 1972|     if(current_params->cd_locale_to_ucs2 == (iconv_t) -1 ||

Error: GCC_ANALYZER_WARNING (CWE-401): [#def33]
libmtp-1.1.22/src/libmtp.c:1976:5: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1974|       LIBMTP_ERROR("LIBMTP PANIC: Cannot open iconv() converters to/from UCS-2!\n"
# 1975|   	    "Too old stdlibc, glibc and libiconv?\n");
# 1976|->     free(current_params);
# 1977|       free(mtp_device);
# 1978|       return NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def34]
libmtp-1.1.22/src/libmtp.c:1984:9: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1982|   
# 1983|     /* Create usbinfo, this also opens the session */
# 1984|->   err = configure_usb_device(rawdevice,
# 1985|   			     current_params,
# 1986|   			     &mtp_device->usbinfo);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def35]
libmtp-1.1.22/src/libmtp.c:1984:9: warning[-Wanalyzer-malloc-leak]: leak of 'current_params'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1982|   
# 1983|     /* Create usbinfo, this also opens the session */
# 1984|->   err = configure_usb_device(rawdevice,
# 1985|   			     current_params,
# 1986|   			     &mtp_device->usbinfo);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def36]
libmtp-1.1.22/src/libmtp.c:1984:9: warning[-Wanalyzer-malloc-leak]: leak of 'mtp_device'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 1982|   
# 1983|     /* Create usbinfo, this also opens the session */
# 1984|->   err = configure_usb_device(rawdevice,
# 1985|   			     current_params,
# 1986|   			     &mtp_device->usbinfo);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def37]
libmtp-1.1.22/src/libmtp.c:2043:12: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL '*tmpext.name' where non-null expected
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 2041|       /* Loop over extensions and set flags */
# 2042|       while (tmpext != NULL) {
# 2043|->       if (!strcmp(tmpext->name, "microsoft.com/WPDNA"))
# 2044|   	is_microsoft_com_wpdna = 1;
# 2045|         if (!strcmp(tmpext->name, "android.com"))

Error: CPPCHECK_WARNING (CWE-476): [#def38]
libmtp-1.1.22/src/libmtp.c:2398: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data
# 2396|     uint16_t ret;
# 2397|   
# 2398|->   data->cb = cb;
# 2399|     data->user_data = user_data;
# 2400|   

Error: CPPCHECK_WARNING (CWE-476): [#def39]
libmtp-1.1.22/src/libmtp.c:2399: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data
# 2397|   
# 2398|     data->cb = cb;
# 2399|->   data->user_data = user_data;
# 2400|   
# 2401|     ret = ptp_usb_event_async(params, LIBMTP_Read_Event_Cb, data);

Error: CPPCHECK_WARNING (CWE-476): [#def40]
libmtp-1.1.22/src/libmtp.c:2563: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: newerror
# 2561|     }
# 2562|     newerror = (LIBMTP_error_t *) malloc(sizeof(LIBMTP_error_t));
# 2563|->   newerror->errornumber = errornumber;
# 2564|     newerror->error_text = strdup(error_text);
# 2565|     newerror->next = NULL;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def41]
libmtp-1.1.22/src/libmtp.c:2563:3: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'newerror'
libmtp-1.1.22/src/libmtp.c:2581:13: enter_function: entry to 'add_ptp_error_to_errorstack'
libmtp-1.1.22/src/libmtp.c:2593:5: call_function: calling 'add_error_to_errorstack' from 'add_ptp_error_to_errorstack'
# 2561|     }
# 2562|     newerror = (LIBMTP_error_t *) malloc(sizeof(LIBMTP_error_t));
# 2563|->   newerror->errornumber = errornumber;
# 2564|     newerror->error_text = strdup(error_text);
# 2565|     newerror->next = NULL;

Error: CPPCHECK_WARNING (CWE-476): [#def42]
libmtp-1.1.22/src/libmtp.c:2564: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: newerror
# 2562|     newerror = (LIBMTP_error_t *) malloc(sizeof(LIBMTP_error_t));
# 2563|     newerror->errornumber = errornumber;
# 2564|->   newerror->error_text = strdup(error_text);
# 2565|     newerror->next = NULL;
# 2566|     if (device->errorstack == NULL) {

Error: CPPCHECK_WARNING (CWE-476): [#def43]
libmtp-1.1.22/src/libmtp.c:2565: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: newerror
# 2563|     newerror->errornumber = errornumber;
# 2564|     newerror->error_text = strdup(error_text);
# 2565|->   newerror->next = NULL;
# 2566|     if (device->errorstack == NULL) {
# 2567|       device->errorstack = newerror;

Error: CPPCHECK_WARNING (CWE-476): [#def44]
libmtp-1.1.22/src/libmtp.c:4019: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: tmp
# 4017|     tmp = malloc((propval.a.count + 1)*sizeof(uint16_t));
# 4018|     for (i = 0; i < propval.a.count; i++) {
# 4019|->     tmp[i] = propval.a.v[i].u16;
# 4020|       // printf("%04x ", tmp[i]);
# 4021|     }

Error: CPPCHECK_WARNING (CWE-476): [#def45]
libmtp-1.1.22/src/libmtp.c:4022: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: tmp
# 4020|       // printf("%04x ", tmp[i]);
# 4021|     }
# 4022|->   tmp[propval.a.count] = 0x0000U;
# 4023|     free(propval.a.v);
# 4024|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def46]
libmtp-1.1.22/src/libmtp.c:4213:17: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 4211|   
# 4212|     if (!ptp_operation_issupported(params,PTP_OC_GetStorageInfo)) {
# 4213|->     for (i = 0; i < storageIDs.n; i++) {
# 4214|   
# 4215|         storage = (LIBMTP_devicestorage_t *)

Error: CPPCHECK_WARNING (CWE-476): [#def47]
libmtp-1.1.22/src/libmtp.c:4217: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4215|         storage = (LIBMTP_devicestorage_t *)
# 4216|   	malloc(sizeof(LIBMTP_devicestorage_t));
# 4217|->       storage->prev = storageprev;
# 4218|         if (storageprev != NULL)
# 4219|           storageprev->next = storage;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def48]
libmtp-1.1.22/src/libmtp.c:4217:7: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'storage'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 4215|         storage = (LIBMTP_devicestorage_t *)
# 4216|   	malloc(sizeof(LIBMTP_devicestorage_t));
# 4217|->       storage->prev = storageprev;
# 4218|         if (storageprev != NULL)
# 4219|           storageprev->next = storage;

Error: CPPCHECK_WARNING (CWE-476): [#def49]
libmtp-1.1.22/src/libmtp.c:4223: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4221|           device->storage = storage;
# 4222|   
# 4223|->       storage->id = storageIDs.Storage[i];
# 4224|         storage->StorageType = PTP_ST_Undefined;
# 4225|         storage->FilesystemType = PTP_FST_Undefined;

Error: CPPCHECK_WARNING (CWE-476): [#def50]
libmtp-1.1.22/src/libmtp.c:4224: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4222|   
# 4223|         storage->id = storageIDs.Storage[i];
# 4224|->       storage->StorageType = PTP_ST_Undefined;
# 4225|         storage->FilesystemType = PTP_FST_Undefined;
# 4226|         storage->AccessCapability = PTP_AC_ReadWrite;

Error: CPPCHECK_WARNING (CWE-476): [#def51]
libmtp-1.1.22/src/libmtp.c:4225: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4223|         storage->id = storageIDs.Storage[i];
# 4224|         storage->StorageType = PTP_ST_Undefined;
# 4225|->       storage->FilesystemType = PTP_FST_Undefined;
# 4226|         storage->AccessCapability = PTP_AC_ReadWrite;
# 4227|         storage->MaxCapacity = (uint64_t) -1;

Error: CPPCHECK_WARNING (CWE-476): [#def52]
libmtp-1.1.22/src/libmtp.c:4226: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4224|         storage->StorageType = PTP_ST_Undefined;
# 4225|         storage->FilesystemType = PTP_FST_Undefined;
# 4226|->       storage->AccessCapability = PTP_AC_ReadWrite;
# 4227|         storage->MaxCapacity = (uint64_t) -1;
# 4228|         storage->FreeSpaceInBytes = (uint64_t) -1;

Error: CPPCHECK_WARNING (CWE-476): [#def53]
libmtp-1.1.22/src/libmtp.c:4227: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4225|         storage->FilesystemType = PTP_FST_Undefined;
# 4226|         storage->AccessCapability = PTP_AC_ReadWrite;
# 4227|->       storage->MaxCapacity = (uint64_t) -1;
# 4228|         storage->FreeSpaceInBytes = (uint64_t) -1;
# 4229|         storage->FreeSpaceInObjects = (uint64_t) -1;

Error: CPPCHECK_WARNING (CWE-476): [#def54]
libmtp-1.1.22/src/libmtp.c:4228: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4226|         storage->AccessCapability = PTP_AC_ReadWrite;
# 4227|         storage->MaxCapacity = (uint64_t) -1;
# 4228|->       storage->FreeSpaceInBytes = (uint64_t) -1;
# 4229|         storage->FreeSpaceInObjects = (uint64_t) -1;
# 4230|         storage->StorageDescription = strdup("Unknown storage");

Error: CPPCHECK_WARNING (CWE-476): [#def55]
libmtp-1.1.22/src/libmtp.c:4229: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4227|         storage->MaxCapacity = (uint64_t) -1;
# 4228|         storage->FreeSpaceInBytes = (uint64_t) -1;
# 4229|->       storage->FreeSpaceInObjects = (uint64_t) -1;
# 4230|         storage->StorageDescription = strdup("Unknown storage");
# 4231|         storage->VolumeIdentifier = strdup("Unknown volume");

Error: CPPCHECK_WARNING (CWE-476): [#def56]
libmtp-1.1.22/src/libmtp.c:4230: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4228|         storage->FreeSpaceInBytes = (uint64_t) -1;
# 4229|         storage->FreeSpaceInObjects = (uint64_t) -1;
# 4230|->       storage->StorageDescription = strdup("Unknown storage");
# 4231|         storage->VolumeIdentifier = strdup("Unknown volume");
# 4232|         storage->next = NULL;

Error: CPPCHECK_WARNING (CWE-476): [#def57]
libmtp-1.1.22/src/libmtp.c:4231: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4229|         storage->FreeSpaceInObjects = (uint64_t) -1;
# 4230|         storage->StorageDescription = strdup("Unknown storage");
# 4231|->       storage->VolumeIdentifier = strdup("Unknown volume");
# 4232|         storage->next = NULL;
# 4233|   

Error: CPPCHECK_WARNING (CWE-476): [#def58]
libmtp-1.1.22/src/libmtp.c:4232: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4230|         storage->StorageDescription = strdup("Unknown storage");
# 4231|         storage->VolumeIdentifier = strdup("Unknown volume");
# 4232|->       storage->next = NULL;
# 4233|   
# 4234|         storageprev = storage;

Error: CPPCHECK_WARNING (CWE-476): [#def59]
libmtp-1.1.22/src/libmtp.c:4253: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4251|         storage = (LIBMTP_devicestorage_t *)
# 4252|   	malloc(sizeof(LIBMTP_devicestorage_t));
# 4253|->       storage->prev = storageprev;
# 4254|         if (storageprev != NULL)
# 4255|           storageprev->next = storage;

Error: CPPCHECK_WARNING (CWE-476): [#def60]
libmtp-1.1.22/src/libmtp.c:4259: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4257|           device->storage = storage;
# 4258|   
# 4259|->       storage->id = storageIDs.Storage[i];
# 4260|         storage->StorageType = storageInfo.StorageType;
# 4261|         storage->FilesystemType = storageInfo.FilesystemType;

Error: CPPCHECK_WARNING (CWE-476): [#def61]
libmtp-1.1.22/src/libmtp.c:4260: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4258|   
# 4259|         storage->id = storageIDs.Storage[i];
# 4260|->       storage->StorageType = storageInfo.StorageType;
# 4261|         storage->FilesystemType = storageInfo.FilesystemType;
# 4262|         storage->AccessCapability = storageInfo.AccessCapability;

Error: CPPCHECK_WARNING (CWE-476): [#def62]
libmtp-1.1.22/src/libmtp.c:4261: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4259|         storage->id = storageIDs.Storage[i];
# 4260|         storage->StorageType = storageInfo.StorageType;
# 4261|->       storage->FilesystemType = storageInfo.FilesystemType;
# 4262|         storage->AccessCapability = storageInfo.AccessCapability;
# 4263|         storage->MaxCapacity = storageInfo.MaxCapability;

Error: CPPCHECK_WARNING (CWE-476): [#def63]
libmtp-1.1.22/src/libmtp.c:4262: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4260|         storage->StorageType = storageInfo.StorageType;
# 4261|         storage->FilesystemType = storageInfo.FilesystemType;
# 4262|->       storage->AccessCapability = storageInfo.AccessCapability;
# 4263|         storage->MaxCapacity = storageInfo.MaxCapability;
# 4264|         storage->FreeSpaceInBytes = storageInfo.FreeSpaceInBytes;

Error: CPPCHECK_WARNING (CWE-476): [#def64]
libmtp-1.1.22/src/libmtp.c:4263: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4261|         storage->FilesystemType = storageInfo.FilesystemType;
# 4262|         storage->AccessCapability = storageInfo.AccessCapability;
# 4263|->       storage->MaxCapacity = storageInfo.MaxCapability;
# 4264|         storage->FreeSpaceInBytes = storageInfo.FreeSpaceInBytes;
# 4265|         storage->FreeSpaceInObjects = storageInfo.FreeSpaceInImages;

Error: CPPCHECK_WARNING (CWE-476): [#def65]
libmtp-1.1.22/src/libmtp.c:4264: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4262|         storage->AccessCapability = storageInfo.AccessCapability;
# 4263|         storage->MaxCapacity = storageInfo.MaxCapability;
# 4264|->       storage->FreeSpaceInBytes = storageInfo.FreeSpaceInBytes;
# 4265|         storage->FreeSpaceInObjects = storageInfo.FreeSpaceInImages;
# 4266|         storage->StorageDescription = storageInfo.StorageDescription;

Error: CPPCHECK_WARNING (CWE-476): [#def66]
libmtp-1.1.22/src/libmtp.c:4265: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4263|         storage->MaxCapacity = storageInfo.MaxCapability;
# 4264|         storage->FreeSpaceInBytes = storageInfo.FreeSpaceInBytes;
# 4265|->       storage->FreeSpaceInObjects = storageInfo.FreeSpaceInImages;
# 4266|         storage->StorageDescription = storageInfo.StorageDescription;
# 4267|         storage->VolumeIdentifier = storageInfo.VolumeLabel;

Error: CPPCHECK_WARNING (CWE-476): [#def67]
libmtp-1.1.22/src/libmtp.c:4266: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4264|         storage->FreeSpaceInBytes = storageInfo.FreeSpaceInBytes;
# 4265|         storage->FreeSpaceInObjects = storageInfo.FreeSpaceInImages;
# 4266|->       storage->StorageDescription = storageInfo.StorageDescription;
# 4267|         storage->VolumeIdentifier = storageInfo.VolumeLabel;
# 4268|         storage->next = NULL;

Error: CPPCHECK_WARNING (CWE-476): [#def68]
libmtp-1.1.22/src/libmtp.c:4267: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4265|         storage->FreeSpaceInObjects = storageInfo.FreeSpaceInImages;
# 4266|         storage->StorageDescription = storageInfo.StorageDescription;
# 4267|->       storage->VolumeIdentifier = storageInfo.VolumeLabel;
# 4268|         storage->next = NULL;
# 4269|   

Error: CPPCHECK_WARNING (CWE-476): [#def69]
libmtp-1.1.22/src/libmtp.c:4268: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: storage
# 4266|         storage->StorageDescription = storageInfo.StorageDescription;
# 4267|         storage->VolumeIdentifier = storageInfo.VolumeLabel;
# 4268|->       storage->next = NULL;
# 4269|   
# 4270|         storageprev = storage;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def70]
libmtp-1.1.22/src/libmtp.c:4280:1: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 4278|       return 0;
# 4279|     }
# 4280|-> }
# 4281|   
# 4282|   /**

Error: GCC_ANALYZER_WARNING (CWE-401): [#def71]
libmtp-1.1.22/src/libmtp.c:4280:1: warning[-Wanalyzer-malloc-leak]: leak of 'storageprev'
libmtp-1.1.22/src/libmtp.c:1729:21: enter_function: entry to 'LIBMTP_Get_Device_By_SerialNumber'
libmtp-1.1.22/src/libmtp.c:1743:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1746:7: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:1746:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:1751:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:1752:14: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:1752:14: call_function: calling 'LIBMTP_Open_Raw_Device' from 'LIBMTP_Get_Device_By_SerialNumber'
# 4278|       return 0;
# 4279|     }
# 4280|-> }
# 4281|   
# 4282|   /**

Error: GCC_ANALYZER_WARNING (CWE-476): [#def72]
libmtp-1.1.22/src/libmtp.c:4348:3: warning[-Wanalyzer-null-dereference]: dereference of NULL 'LIBMTP_new_file_t()'
libmtp-1.1.22/src/libmtp.c:9225:5: enter_function: entry to 'LIBMTP_GetPartialObject'
libmtp-1.1.22/src/libmtp.c:9231:28: call_function: calling 'LIBMTP_Get_Filemetadata' from 'LIBMTP_GetPartialObject'
# 4346|     file = LIBMTP_new_file_t();
# 4347|   
# 4348|->   file->parent_id = ob->oi.ParentObject;
# 4349|     file->storage_id = ob->oi.StorageID;
# 4350|   

Error: COMPILER_WARNING (CWE-704): [#def73]
libmtp-1.1.22/src/libmtp.c: scope_hint: In function 'generate_unique_filename'
libmtp-1.1.22/src/libmtp.c:5720:24: warning[-Wdiscarded-qualifiers]: assignment discards 'const' qualifier from pointer target type
# 5720 |     extension_position = strrchr(filename,'.');
#      |                        ^
# 5718|     if (check_filename_exists(params, filename))
# 5719|     {
# 5720|->     extension_position = strrchr(filename,'.');
# 5721|   
# 5722|       char basename[extension_position - filename + 1];

Error: COMPILER_WARNING (CWE-704): [#def74]
libmtp-1.1.22/src/libmtp.c:5720:24: warning[-Wdiscarded-qualifiers]: assignment discards 'const' qualifier from pointer target type
# 5718|     if (check_filename_exists(params, filename))
# 5719|     {
# 5720|->     extension_position = strrchr(filename,'.');
# 5721|   
# 5722|       char basename[extension_position - filename + 1];

Error: CPPCHECK_WARNING (CWE-476): [#def75]
libmtp-1.1.22/src/libmtp.c:7620: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: props
# 7618|   	MTPProperties *props = (MTPProperties*)calloc(2,sizeof(MTPProperties));
# 7619|   
# 7620|-> 	props[0].property = PTP_OPC_ObjectFileName;
# 7621|   	props[0].datatype = PTP_DTC_STR;
# 7622|   	props[0].propval.str = name;

Error: CPPCHECK_WARNING (CWE-476): [#def76]
libmtp-1.1.22/src/libmtp.c:7621: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: props
# 7619|   
# 7620|   	props[0].property = PTP_OPC_ObjectFileName;
# 7621|-> 	props[0].datatype = PTP_DTC_STR;
# 7622|   	props[0].propval.str = name;
# 7623|   

Error: CPPCHECK_WARNING (CWE-476): [#def77]
libmtp-1.1.22/src/libmtp.c:7622: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: props
# 7620|   	props[0].property = PTP_OPC_ObjectFileName;
# 7621|   	props[0].datatype = PTP_DTC_STR;
# 7622|-> 	props[0].propval.str = name;
# 7623|   
# 7624|   	props[1].property = PTP_OPC_Name;

Error: CPPCHECK_WARNING (CWE-476): [#def78]
libmtp-1.1.22/src/libmtp.c:7624: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: props
# 7622|   	props[0].propval.str = name;
# 7623|   
# 7624|-> 	props[1].property = PTP_OPC_Name;
# 7625|   	props[1].datatype = PTP_DTC_STR;
# 7626|   	props[1].propval.str = name;

Error: CPPCHECK_WARNING (CWE-476): [#def79]
libmtp-1.1.22/src/libmtp.c:7625: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: props
# 7623|   
# 7624|   	props[1].property = PTP_OPC_Name;
# 7625|-> 	props[1].datatype = PTP_DTC_STR;
# 7626|   	props[1].propval.str = name;
# 7627|   

Error: CPPCHECK_WARNING (CWE-476): [#def80]
libmtp-1.1.22/src/libmtp.c:7626: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: props
# 7624|   	props[1].property = PTP_OPC_Name;
# 7625|   	props[1].datatype = PTP_DTC_STR;
# 7626|-> 	props[1].propval.str = name;
# 7627|   
# 7628|   	ret = ptp_mtp_sendobjectproplist(params, &store, &parenthandle, &new_id, PTP_OFC_Association,

Error: GCC_ANALYZER_WARNING (CWE-401): [#def81]
libmtp-1.1.22/src/libmtp.c:8564:7: warning[-Wanalyzer-malloc-leak]: leak of '*alb.name'
libmtp-1.1.22/src/libmtp.c:8606:13: enter_function: entry to 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8622:7: return_function: returning to 'get_album_metadata' from 'pick_property_to_album_metadata'
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
# 8562|     case PTP_OPC_Name:
# 8563|       if (prop->propval.str != NULL)
# 8564|->       alb->name = strdup(prop->propval.str);
# 8565|       else
# 8566|         alb->name = NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def82]
libmtp-1.1.22/src/libmtp.c:8564:7: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8562|     case PTP_OPC_Name:
# 8563|       if (prop->propval.str != NULL)
# 8564|->       alb->name = strdup(prop->propval.str);
# 8565|       else
# 8566|         alb->name = NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def83]
libmtp-1.1.22/src/libmtp.c:8566:7: warning[-Wanalyzer-malloc-leak]: leak of '*alb.name'
libmtp-1.1.22/src/libmtp.c:8606:13: enter_function: entry to 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8622:7: return_function: returning to 'get_album_metadata' from 'pick_property_to_album_metadata'
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
# 8564|         alb->name = strdup(prop->propval.str);
# 8565|       else
# 8566|->       alb->name = NULL;
# 8567|       break;
# 8568|     case PTP_OPC_AlbumArtist:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def84]
libmtp-1.1.22/src/libmtp.c:8566:7: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8564|         alb->name = strdup(prop->propval.str);
# 8565|       else
# 8566|->       alb->name = NULL;
# 8567|       break;
# 8568|     case PTP_OPC_AlbumArtist:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def85]
libmtp-1.1.22/src/libmtp.c:8575:7: warning[-Wanalyzer-malloc-leak]: leak of '*alb.artist'
libmtp-1.1.22/src/libmtp.c:8606:13: enter_function: entry to 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8622:7: return_function: returning to 'get_album_metadata' from 'pick_property_to_album_metadata'
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
# 8573|         alb->artist = strdup(prop->propval.str);
# 8574|       } else
# 8575|->       alb->artist = NULL;
# 8576|       break;
# 8577|     case PTP_OPC_Artist:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def86]
libmtp-1.1.22/src/libmtp.c:8575:7: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8573|         alb->artist = strdup(prop->propval.str);
# 8574|       } else
# 8575|->       alb->artist = NULL;
# 8576|       break;
# 8577|     case PTP_OPC_Artist:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def87]
libmtp-1.1.22/src/libmtp.c:8583:7: warning[-Wanalyzer-malloc-leak]: leak of '*alb.artist'
libmtp-1.1.22/src/libmtp.c:8606:13: enter_function: entry to 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8622:7: return_function: returning to 'get_album_metadata' from 'pick_property_to_album_metadata'
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
# 8581|   	alb->artist = strdup(prop->propval.str);
# 8582|       } else
# 8583|->       alb->artist = NULL;
# 8584|       break;
# 8585|     case PTP_OPC_Composer:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def88]
libmtp-1.1.22/src/libmtp.c:8583:7: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8581|   	alb->artist = strdup(prop->propval.str);
# 8582|       } else
# 8583|->       alb->artist = NULL;
# 8584|       break;
# 8585|     case PTP_OPC_Composer:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def89]
libmtp-1.1.22/src/libmtp.c:8587:7: warning[-Wanalyzer-malloc-leak]: leak of '*alb.composer'
libmtp-1.1.22/src/libmtp.c:8606:13: enter_function: entry to 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8622:7: return_function: returning to 'get_album_metadata' from 'pick_property_to_album_metadata'
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
# 8585|     case PTP_OPC_Composer:
# 8586|       if (prop->propval.str != NULL)
# 8587|->       alb->composer = strdup(prop->propval.str);
# 8588|       else
# 8589|         alb->composer = NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def90]
libmtp-1.1.22/src/libmtp.c:8587:7: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8585|     case PTP_OPC_Composer:
# 8586|       if (prop->propval.str != NULL)
# 8587|->       alb->composer = strdup(prop->propval.str);
# 8588|       else
# 8589|         alb->composer = NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def91]
libmtp-1.1.22/src/libmtp.c:8589:7: warning[-Wanalyzer-malloc-leak]: leak of '*alb.composer'
libmtp-1.1.22/src/libmtp.c:8606:13: enter_function: entry to 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8622:7: return_function: returning to 'get_album_metadata' from 'pick_property_to_album_metadata'
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
# 8587|         alb->composer = strdup(prop->propval.str);
# 8588|       else
# 8589|->       alb->composer = NULL;
# 8590|       break;
# 8591|     case PTP_OPC_Genre:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def92]
libmtp-1.1.22/src/libmtp.c:8589:7: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8587|         alb->composer = strdup(prop->propval.str);
# 8588|       else
# 8589|->       alb->composer = NULL;
# 8590|       break;
# 8591|     case PTP_OPC_Genre:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def93]
libmtp-1.1.22/src/libmtp.c:8593:7: warning[-Wanalyzer-malloc-leak]: leak of '*alb.genre'
libmtp-1.1.22/src/libmtp.c:8606:13: enter_function: entry to 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8622:7: return_function: returning to 'get_album_metadata' from 'pick_property_to_album_metadata'
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
# 8591|     case PTP_OPC_Genre:
# 8592|       if (prop->propval.str != NULL)
# 8593|->       alb->genre = strdup(prop->propval.str);
# 8594|       else
# 8595|         alb->genre = NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def94]
libmtp-1.1.22/src/libmtp.c:8593:7: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8591|     case PTP_OPC_Genre:
# 8592|       if (prop->propval.str != NULL)
# 8593|->       alb->genre = strdup(prop->propval.str);
# 8594|       else
# 8595|         alb->genre = NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def95]
libmtp-1.1.22/src/libmtp.c:8595:7: warning[-Wanalyzer-malloc-leak]: leak of '*alb.genre'
libmtp-1.1.22/src/libmtp.c:8606:13: enter_function: entry to 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8619:6: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
libmtp-1.1.22/src/libmtp.c:8622:7: return_function: returning to 'get_album_metadata' from 'pick_property_to_album_metadata'
libmtp-1.1.22/src/libmtp.c:8621:14: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8622:7: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8622:7: call_function: calling 'pick_property_to_album_metadata' from 'get_album_metadata'
# 8593|         alb->genre = strdup(prop->propval.str);
# 8594|       else
# 8595|->       alb->genre = NULL;
# 8596|       break;
# 8597|     }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def96]
libmtp-1.1.22/src/libmtp.c:8595:7: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8593|         alb->genre = strdup(prop->propval.str);
# 8594|       else
# 8595|->       alb->genre = NULL;
# 8596|       break;
# 8597|     }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def97]
libmtp-1.1.22/src/libmtp.c:8719:5: warning[-Wanalyzer-null-dereference]: dereference of NULL 'LIBMTP_new_album_t()'
libmtp-1.1.22/src/libmtp.c:8691:17: enter_function: entry to 'LIBMTP_Get_Album_List_For_Storage'
libmtp-1.1.22/src/libmtp.c:8699:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8702:3: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8702:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8707:11: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8718:11: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album_List_For_Storage'
libmtp-1.1.22/src/libmtp.c:8718:11: return_function: returning to 'LIBMTP_Get_Album_List_For_Storage' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8719:5: danger: dereference of NULL 'LIBMTP_new_album_t()'
# 8717|       // Allocate a new album type
# 8718|       alb = LIBMTP_new_album_t();
# 8719|->     alb->album_id = ob->oid;
# 8720|       alb->parent_id = ob->oi.ParentObject;
# 8721|       alb->storage_id = ob->oi.StorageID;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def98]
libmtp-1.1.22/src/libmtp.c:8719:21: warning[-Wanalyzer-malloc-leak]: leak of 'LIBMTP_new_album_t()'
libmtp-1.1.22/src/libmtp.c:8691:17: enter_function: entry to 'LIBMTP_Get_Album_List_For_Storage'
libmtp-1.1.22/src/libmtp.c:8699:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8702:3: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8702:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:8707:11: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:8718:11: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album_List_For_Storage'
libmtp-1.1.22/src/libmtp.c:8718:11: return_function: returning to 'LIBMTP_Get_Album_List_For_Storage' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8724:5: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album_List_For_Storage'
# 8717|       // Allocate a new album type
# 8718|       alb = LIBMTP_new_album_t();
# 8719|->     alb->album_id = ob->oid;
# 8720|       alb->parent_id = ob->oi.ParentObject;
# 8721|       alb->storage_id = ob->oi.StorageID;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def99]
libmtp-1.1.22/src/libmtp.c:8775:3: warning[-Wanalyzer-null-dereference]: dereference of NULL 'LIBMTP_new_album_t()'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8775:3: danger: dereference of NULL 'LIBMTP_new_album_t()'
# 8773|     // Allocate a new album type
# 8774|     alb = LIBMTP_new_album_t();
# 8775|->   alb->album_id = ob->oid;
# 8776|     alb->parent_id = ob->oi.ParentObject;
# 8777|     alb->storage_id = ob->oi.StorageID;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def100]
libmtp-1.1.22/src/libmtp.c:8775:21: warning[-Wanalyzer-malloc-leak]: leak of 'LIBMTP_new_album_t()'
libmtp-1.1.22/src/libmtp.c:8754:17: enter_function: entry to 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8762:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8765:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8766:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8770:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8770:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:8774:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:8774:9: call_function: calling 'LIBMTP_new_album_t' from 'LIBMTP_Get_Album'
libmtp-1.1.22/src/libmtp.c:8774:9: return_function: returning to 'LIBMTP_Get_Album' from 'LIBMTP_new_album_t'
libmtp-1.1.22/src/libmtp.c:8780:3: call_function: calling 'get_album_metadata' from 'LIBMTP_Get_Album'
# 8773|     // Allocate a new album type
# 8774|     alb = LIBMTP_new_album_t();
# 8775|->   alb->album_id = ob->oid;
# 8776|     alb->parent_id = ob->oi.ParentObject;
# 8777|     alb->storage_id = ob->oi.StorageID;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def101]
libmtp-1.1.22/src/libmtp.c:9088:5: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'propval.a.v'
libmtp-1.1.22/src/libmtp.c:9059:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:9065:51: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9066:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:9066:6: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9077:6: branch_false: following 'false' branch (when 'supported != 0')...
libmtp-1.1.22/src/libmtp.c:9082:3: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9086:17: acquire_memory: this call could return NULL
libmtp-1.1.22/src/libmtp.c:9087:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:9088:25: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:9088:5: danger: 'malloc(*sampledata.size * 16) + (long unsigned int)i * 16' could be NULL: unchecked value from [(7)](sarif:/runs/0/results/48/codeFlows/0/threadFlows/0/locations/6)
# 9086|     propval.a.v = malloc(sizeof(PTPPropertyValue) * sampledata->size);
# 9087|     for (i = 0; i < sampledata->size; i++) {
# 9088|->     propval.a.v[i].u8 = sampledata->data[i];
# 9089|     }
# 9090|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def102]
libmtp-1.1.22/src/libmtp.c:9091:9: warning[-Wanalyzer-malloc-leak]: leak of 'propval.a.v'
libmtp-1.1.22/src/libmtp.c:9059:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:9065:51: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9066:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:9066:6: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9077:6: branch_false: following 'false' branch (when 'supported != 0')...
libmtp-1.1.22/src/libmtp.c:9082:3: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9086:17: acquire_memory: allocated here
libmtp-1.1.22/src/libmtp.c:9087:15: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:9091:9: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9091:9: throw: if 'ptp_mtp_setobjectpropvalue' throws an exception...
libmtp-1.1.22/src/libmtp.c:9091:9: danger: 'propval.a.v' leaks here; was allocated at [(7)](sarif:/runs/0/results/49/codeFlows/0/threadFlows/0/locations/6)
# 9089|     }
# 9090|   
# 9091|->   ret = ptp_mtp_setobjectpropvalue(params,id,PTP_OPC_RepresentativeSampleData,
# 9092|   				   &propval,PTP_DTC_AUINT8);
# 9093|     if (ret != PTP_RC_OK) {

Error: GCC_ANALYZER_WARNING (CWE-476): [#def103]
libmtp-1.1.22/src/libmtp.c:9190:5: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL '*sampledata.data'
libmtp-1.1.22/src/libmtp.c:9153:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:9159:51: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9160:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:9160:6: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9171:6: branch_false: following 'false' branch (when 'supported != 0')...
libmtp-1.1.22/src/libmtp.c:9176:3: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9181:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libmtp.c:9187:22: branch_false: ...to here
libmtp-1.1.22/src/libmtp.c:9188:22: acquire_memory: this call could return NULL
libmtp-1.1.22/src/libmtp.c:9189:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libmtp.c:9190:27: branch_true: ...to here
libmtp-1.1.22/src/libmtp.c:9190:5: danger: '*sampledata.data + (long unsigned int)i' could be NULL: unchecked value from [(9)](sarif:/runs/0/results/51/codeFlows/0/threadFlows/0/locations/8)
# 9188|     sampledata->data = malloc(sizeof(PTPPropertyValue) * propval.a.count);
# 9189|     for (i = 0; i < propval.a.count; i++) {
# 9190|->     sampledata->data[i] = propval.a.v[i].u8;
# 9191|     }
# 9192|     free(propval.a.v);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def104]
libmtp-1.1.22/src/libusb1-glue.c:249:9: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2271:12: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2271:12: call_function: calling 'probe_device_descriptor' from 'configure_usb_device'
#  247|     struct libusb_device_descriptor desc;
#  248|   
#  249|->   ret = libusb_get_device_descriptor (dev, &desc);
#  250|     if (ret != LIBUSB_SUCCESS) return 0;
#  251|     /*

Error: GCC_ANALYZER_WARNING (CWE-401): [#def105]
libmtp-1.1.22/src/libusb1-glue.c:272:9: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2271:12: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2271:12: call_function: calling 'probe_device_descriptor' from 'configure_usb_device'
#  270|      * like it at all either :-(
#  271|      */
#  272|->   ret = libusb_open(dev, &devh);
#  273|     if (ret != LIBUSB_SUCCESS) {
#  274|       /* Could not open this device */

Error: GCC_ANALYZER_WARNING (CWE-401): [#def106]
libmtp-1.1.22/src/libusb1-glue.c:288:12: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2271:12: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2271:12: call_function: calling 'probe_device_descriptor' from 'configure_usb_device'
#  286|        struct libusb_config_descriptor *config;
#  287|   
#  288|->      ret = libusb_get_config_descriptor (dev, i, &config);
#  289|        if (ret != LIBUSB_SUCCESS) {
#  290|          LIBMTP_INFO("configdescriptor %d get failed with ret %d in probe_device_descriptor yet dev->descriptor.bNumConfigurations > 0\n", i, ret);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def107]
libmtp-1.1.22/src/libusb1-glue.c:399:7: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2271:12: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2271:12: call_function: calling 'probe_device_descriptor' from 'configure_usb_device'
#  397|       if (ret < 0) {
#  398|         /* EP0 is the default control endpoint */
#  399|->       libusb_clear_halt (devh, 0);
#  400|         libusb_close(devh);
#  401|         return 0;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def108]
libmtp-1.1.22/src/libusb1-glue.c:400:7: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2271:12: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2271:12: call_function: calling 'probe_device_descriptor' from 'configure_usb_device'
#  398|         /* EP0 is the default control endpoint */
#  399|         libusb_clear_halt (devh, 0);
#  400|->       libusb_close(devh);
#  401|         return 0;
#  402|       }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def109]
libmtp-1.1.22/src/libusb1-glue.c:412:7: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2271:12: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2271:12: call_function: calling 'probe_device_descriptor' from 'configure_usb_device'
#  410|       /* Check if descriptor length is at least 10 bytes */
#  411|       if (ret < 10) {
#  412|->       libusb_close(devh);
#  413|         return 0;
#  414|       }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def110]
libmtp-1.1.22/src/libusb1-glue.c:547:13: warning[-Wanalyzer-malloc-leak]: leak of 'devlist'
libmtp-1.1.22/src/libusb1-glue.c:632:23: enter_function: entry to 'LIBMTP_Detect_Raw_Devices'
libmtp-1.1.22/src/libusb1-glue.c:642:9: call_function: calling 'get_mtp_usb_device_list' from 'LIBMTP_Detect_Raw_Devices'
#  545|               desc.idProduct == mtp_device_table[i].product_id) {
#  546|               /* Append this usb device to the MTP device list */
#  547|->             *mtp_device_list = append_to_mtpdevice_list(*mtp_device_list,
#  548|   							dev,
#  549|   							libusb_get_bus_number(dev));

Error: GCC_ANALYZER_WARNING (CWE-404): [#def111]
libmtp-1.1.22/src/libusb1-glue.c:784:17: warning[-Wanalyzer-va-list-leak]: missing call to 'va_end'
libmtp-1.1.22/src/libusb1-glue.c:782:9: acquire_resource: 'va_start' called here
libmtp-1.1.22/src/libusb1-glue.c:783:12: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:784:17: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:784:17: throw: if the called function throws an exception...
libmtp-1.1.22/src/libusb1-glue.c:784:17: danger: missing call to 'va_end' to match 'va_start' at [(1)](sarif:/runs/0/results/8/codeFlows/0/threadFlows/0/locations/0)
#  782|           va_start (args, format);
#  783|           if (params->debug_func!=NULL)
#  784|->                 params->debug_func (params->data, format, args);
#  785|           else
#  786|   	{

Error: GCC_ANALYZER_WARNING (CWE-404): [#def112]
libmtp-1.1.22/src/libusb1-glue.c:789:17: warning[-Wanalyzer-va-list-leak]: missing call to 'va_end'
libmtp-1.1.22/src/libusb1-glue.c:782:9: acquire_resource: 'va_start' called here
libmtp-1.1.22/src/libusb1-glue.c:783:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:787:17: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:789:17: throw: if 'fflush' throws an exception...
libmtp-1.1.22/src/libusb1-glue.c:789:17: danger: missing call to 'va_end' to match 'va_start' at [(1)](sarif:/runs/0/results/9/codeFlows/0/threadFlows/0/locations/0)
#  787|                   vfprintf (stderr, format, args);
#  788|   		fprintf (stderr,"\n");
#  789|-> 		fflush (stderr);
#  790|   	}
#  791|           va_end (args);

Error: GCC_ANALYZER_WARNING (CWE-404): [#def113]
libmtp-1.1.22/src/libusb1-glue.c:801:17: warning[-Wanalyzer-va-list-leak]: missing call to 'va_end'
libmtp-1.1.22/src/libusb1-glue.c:799:9: acquire_resource: 'va_start' called here
libmtp-1.1.22/src/libusb1-glue.c:800:12: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:801:17: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:801:17: throw: if the called function throws an exception...
libmtp-1.1.22/src/libusb1-glue.c:801:17: danger: missing call to 'va_end' to match 'va_start' at [(1)](sarif:/runs/0/results/10/codeFlows/0/threadFlows/0/locations/0)
#  799|           va_start (args, format);
#  800|           if (params->error_func!=NULL)
#  801|->                 params->error_func (params->data, format, args);
#  802|           else
#  803|   	{

Error: GCC_ANALYZER_WARNING (CWE-404): [#def114]
libmtp-1.1.22/src/libusb1-glue.c:806:17: warning[-Wanalyzer-va-list-leak]: missing call to 'va_end'
libmtp-1.1.22/src/libusb1-glue.c:799:9: acquire_resource: 'va_start' called here
libmtp-1.1.22/src/libusb1-glue.c:800:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:804:17: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:806:17: throw: if 'fflush' throws an exception...
libmtp-1.1.22/src/libusb1-glue.c:806:17: danger: missing call to 'va_end' to match 'va_start' at [(1)](sarif:/runs/0/results/11/codeFlows/0/threadFlows/0/locations/0)
#  804|                   vfprintf (stderr, format, args);
#  805|   		fprintf (stderr,"\n");
#  806|-> 		fflush (stderr);
#  807|   	}
#  808|           va_end (args);

Error: GCC_ANALYZER_WARNING (CWE-457): [#def115]
libmtp-1.1.22/src/libusb1-glue.c:888:21: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value 'context_block_size_1'
libmtp-1.1.22/src/libusb1-glue.c:1006:1: enter_function: entry to 'ptp_read_cancel_func'
libmtp-1.1.22/src/libusb1-glue.c:1034:11: call_function: calling 'ptp_read_func' from 'ptp_read_cancel_func'
#  886|   		    // we are first packet, but not last packet
#  887|   		    toread = context_block_size_1;
#  888|-> 	    else if (toread == context_block_size_1)
#  889|   		    toread = context_block_size_2;
#  890|   	    else if (toread == context_block_size_2)

Error: COMPILER_WARNING (CWE-457): [#def116]
libmtp-1.1.22/src/libusb1-glue.c: scope_hint: In function 'ptp_read_func'
libmtp-1.1.22/src/libusb1-glue.c:888:21: warning[-Wmaybe-uninitialized]: 'context_block_size_1' may be used uninitialized
#  888 |             else if (toread == context_block_size_1)
#      |                     ^
libmtp-1.1.22/src/libusb1-glue.c:851:17: note: 'context_block_size_1' was declared here
#  851 |   unsigned long context_block_size_1;
#      |                 ^~~~~~~~~~~~~~~~~~~~
#  886|   		    // we are first packet, but not last packet
#  887|   		    toread = context_block_size_1;
#  888|-> 	    else if (toread == context_block_size_1)
#  889|   		    toread = context_block_size_2;
#  890|   	    else if (toread == context_block_size_2)

Error: COMPILER_WARNING (CWE-457): [#def117]
libmtp-1.1.22/src/libusb1-glue.c:890:21: warning[-Wmaybe-uninitialized]: 'context_block_size_2' may be used uninitialized
#  890 |             else if (toread == context_block_size_2)
#      |                     ^
libmtp-1.1.22/src/libusb1-glue.c:852:17: note: 'context_block_size_2' was declared here
#  852 |   unsigned long context_block_size_2;
#      |                 ^~~~~~~~~~~~~~~~~~~~
#  888|   	    else if (toread == context_block_size_1)
#  889|   		    toread = context_block_size_2;
#  890|-> 	    else if (toread == context_block_size_2)
#  891|   		    toread = context_block_size_1;
#  892|   	    else

Error: GCC_ANALYZER_WARNING (CWE-457): [#def118]
libmtp-1.1.22/src/libusb1-glue.c:899:5: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value 'toread'
libmtp-1.1.22/src/libusb1-glue.c:1377:17: enter_function: entry to 'ptp_usb_getpacket'
libmtp-1.1.22/src/libusb1-glue.c:1389:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:1399:9: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1400:15: call_function: calling 'ptp_read_func' from 'ptp_usb_getpacket'
#  897|   	    toread = CONTEXT_BLOCK_SIZE;
#  898|   
#  899|->     LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread);
#  900|   
#  901|       ret = USB_BULK_READ(ptp_usb->handle,

Error: GCC_ANALYZER_WARNING (CWE-401): [#def119]
libmtp-1.1.22/src/libusb1-glue.c:901:11: warning[-Wanalyzer-malloc-leak]: leak of 'bytes'
libmtp-1.1.22/src/libusb1-glue.c:856:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:868:11: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:868:11: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:869:10: branch_true: following 'true' branch (when 'curread < size')...
libmtp-1.1.22/src/libusb1-glue.c:870:5: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:873:8: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:878:10: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:878:10: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:899:5: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:899:5: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:901:11: throw: if 'libusb_bulk_transfer' throws an exception...
libmtp-1.1.22/src/libusb1-glue.c:901:11: danger: 'bytes' leaks here; was allocated at [(3)](sarif:/runs/0/results/23/codeFlows/0/threadFlows/0/locations/2)
#  899|       LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread);
#  900|   
#  901|->     ret = USB_BULK_READ(ptp_usb->handle,
#  902|                           ptp_usb->inep,
#  903|                           bytes,

Error: GCC_ANALYZER_WARNING (CWE-401): [#def120]
libmtp-1.1.22/src/libusb1-glue.c:901:11: warning[-Wanalyzer-malloc-leak]: leak of 'memhandler.priv'
libmtp-1.1.22/src/libusb1-glue.c:1377:17: enter_function: entry to 'ptp_usb_getpacket'
libmtp-1.1.22/src/libusb1-glue.c:1389:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:1399:9: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1399:9: call_function: calling 'ptp_init_recv_memory_handler' from 'ptp_usb_getpacket'
libmtp-1.1.22/src/libusb1-glue.c:1399:9: return_function: returning to 'ptp_usb_getpacket' from 'ptp_init_recv_memory_handler'
libmtp-1.1.22/src/libusb1-glue.c:1400:15: call_function: calling 'ptp_read_func' from 'ptp_usb_getpacket'
#  899|       LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread);
#  900|   
#  901|->     ret = USB_BULK_READ(ptp_usb->handle,
#  902|                           ptp_usb->inep,
#  903|                           bytes,

Error: GCC_ANALYZER_WARNING (CWE-457): [#def121]
libmtp-1.1.22/src/libusb1-glue.c:901:11: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value 'toread'
libmtp-1.1.22/src/libusb1-glue.c:1377:17: enter_function: entry to 'ptp_usb_getpacket'
libmtp-1.1.22/src/libusb1-glue.c:1389:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:1399:9: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1400:15: call_function: calling 'ptp_read_func' from 'ptp_usb_getpacket'
#  899|       LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread);
#  900|   
#  901|->     ret = USB_BULK_READ(ptp_usb->handle,
#  902|                           ptp_usb->inep,
#  903|                           bytes,

Error: GCC_ANALYZER_WARNING (CWE-401): [#def122]
libmtp-1.1.22/src/libusb1-glue.c:921:7: warning[-Wanalyzer-malloc-leak]: leak of 'memhandler.priv'
libmtp-1.1.22/src/libusb1-glue.c:1377:17: enter_function: entry to 'ptp_usb_getpacket'
libmtp-1.1.22/src/libusb1-glue.c:1389:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:1399:9: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1399:9: call_function: calling 'ptp_init_recv_memory_handler' from 'ptp_usb_getpacket'
libmtp-1.1.22/src/libusb1-glue.c:1399:9: return_function: returning to 'ptp_usb_getpacket' from 'ptp_init_recv_memory_handler'
libmtp-1.1.22/src/libusb1-glue.c:1400:15: call_function: calling 'ptp_read_func' from 'ptp_usb_getpacket'
#  919|         LIBMTP_USB_DEBUG("Zero Read\n");
#  920|       else
#  921|->       LIBMTP_USB_DATA(bytes, xread, 16);
#  922|   
#  923|       // want to discard extra byte

Error: GCC_ANALYZER_WARNING (CWE-401): [#def123]
libmtp-1.1.22/src/libusb1-glue.c:1088:23: warning[-Wanalyzer-malloc-leak]: leak of 'bytes'
libmtp-1.1.22/src/libusb1-glue.c:1071:11: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:1072:6: branch_false: following 'false' branch (when 'bytes' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:1072:6: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1075:10: branch_true: following 'true' branch (when 'curwrite < size')...
libmtp-1.1.22/src/libusb1-glue.c:1077:9: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1080:8: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:1081:7: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1088:23: throw: if the called function throws an exception...
libmtp-1.1.22/src/libusb1-glue.c:1088:23: danger: 'bytes' leaks here; was allocated at [(1)](sarif:/runs/0/results/25/codeFlows/0/threadFlows/0/locations/0)
# 1086|         }
# 1087|       }
# 1088|->     int getfunc_ret = handler->getfunc(NULL, handler->priv,towrite,bytes,&towrite);
# 1089|       if (getfunc_ret != PTP_RC_OK) {
# 1090|         free(bytes);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def124]
libmtp-1.1.22/src/libusb1-glue.c:1094:19: warning[-Wanalyzer-malloc-leak]: leak of 'bytes'
libmtp-1.1.22/src/libusb1-glue.c:1305:1: enter_function: entry to 'ptp_usb_senddata'
libmtp-1.1.22/src/libusb1-glue.c:1331:12: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:1346:15: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1346:15: call_function: calling 'ptp_init_send_memory_handler' from 'ptp_usb_senddata'
libmtp-1.1.22/src/libusb1-glue.c:1346:15: return_function: returning to 'ptp_usb_senddata' from 'ptp_init_send_memory_handler'
libmtp-1.1.22/src/libusb1-glue.c:1347:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:1351:15: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1351:15: call_function: calling 'ptp_write_func' from 'ptp_usb_senddata'
# 1092|       }
# 1093|       while (usbwritten < towrite) {
# 1094|-> 	    ret = USB_BULK_WRITE(ptp_usb->handle,
# 1095|   				    ptp_usb->outep,
# 1096|   				    bytes+usbwritten,

Error: GCC_ANALYZER_WARNING (CWE-401): [#def125]
libmtp-1.1.22/src/libusb1-glue.c:1094:19: warning[-Wanalyzer-malloc-leak]: leak of 'memhandler.priv'
libmtp-1.1.22/src/libusb1-glue.c:1305:1: enter_function: entry to 'ptp_usb_senddata'
libmtp-1.1.22/src/libusb1-glue.c:1331:12: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:1346:15: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1346:15: call_function: calling 'ptp_init_send_memory_handler' from 'ptp_usb_senddata'
libmtp-1.1.22/src/libusb1-glue.c:1346:15: return_function: returning to 'ptp_usb_senddata' from 'ptp_init_send_memory_handler'
libmtp-1.1.22/src/libusb1-glue.c:1347:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:1351:15: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1351:15: call_function: calling 'ptp_write_func' from 'ptp_usb_senddata'
# 1092|       }
# 1093|       while (usbwritten < towrite) {
# 1094|-> 	    ret = USB_BULK_WRITE(ptp_usb->handle,
# 1095|   				    ptp_usb->outep,
# 1096|   				    bytes+usbwritten,

Error: GCC_ANALYZER_WARNING (CWE-401): [#def126]
libmtp-1.1.22/src/libusb1-glue.c:1107:13: warning[-Wanalyzer-malloc-leak]: leak of 'memhandler.priv'
libmtp-1.1.22/src/libusb1-glue.c:1305:1: enter_function: entry to 'ptp_usb_senddata'
libmtp-1.1.22/src/libusb1-glue.c:1331:12: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:1346:15: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1346:15: call_function: calling 'ptp_init_send_memory_handler' from 'ptp_usb_senddata'
libmtp-1.1.22/src/libusb1-glue.c:1346:15: return_function: returning to 'ptp_usb_senddata' from 'ptp_init_send_memory_handler'
libmtp-1.1.22/src/libusb1-glue.c:1347:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:1351:15: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1351:15: call_function: calling 'ptp_write_func' from 'ptp_usb_senddata'
# 1105|   	      return PTP_ERROR_IO;
# 1106|   	    }
# 1107|-> 	    LIBMTP_USB_DATA(bytes+usbwritten, xwritten, 16);
# 1108|   	    // check for result == 0 perhaps too.
# 1109|   	    // Increase counters

Error: GCC_ANALYZER_WARNING (CWE-688): [#def127]
libmtp-1.1.22/src/libusb1-glue.c:1194:9: warning[-Wanalyzer-null-argument]: use of NULL where non-null expected
libmtp-1.1.22/src/libusb1-glue.c:1377:17: enter_function: entry to 'ptp_usb_getpacket'
libmtp-1.1.22/src/libusb1-glue.c:1389:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:1399:9: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1399:9: call_function: calling 'ptp_init_recv_memory_handler' from 'ptp_usb_getpacket'
libmtp-1.1.22/src/libusb1-glue.c:1399:9: return_function: returning to 'ptp_usb_getpacket' from 'ptp_init_recv_memory_handler'
libmtp-1.1.22/src/libusb1-glue.c:1400:15: call_function: calling 'ptp_read_func' from 'ptp_usb_getpacket'
# 1192|   		priv->size = priv->curoff + sendlen;
# 1193|   	}
# 1194|-> 	memcpy (priv->data + priv->curoff, data, sendlen);
# 1195|   	priv->curoff += sendlen;
# 1196|   	return PTP_RC_OK;

Error: CPPCHECK_WARNING (CWE-476): [#def128]
libmtp-1.1.22/src/libusb1-glue.c:1207: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: priv
# 1205|   	handler->getfunc = memory_getfunc;
# 1206|   	handler->putfunc = memory_putfunc;
# 1207|-> 	priv->data = NULL;
# 1208|   	priv->size = 0;
# 1209|   	priv->curoff = 0;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def129]
libmtp-1.1.22/src/libusb1-glue.c:1207:9: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'priv'
libmtp-1.1.22/src/libusb1-glue.c:1203:16: acquire_memory: this call could return NULL
libmtp-1.1.22/src/libusb1-glue.c:1207:9: danger: 'priv' could be NULL: unchecked value from [(1)](sarif:/runs/0/results/32/codeFlows/0/threadFlows/0/locations/0)
# 1205|   	handler->getfunc = memory_getfunc;
# 1206|   	handler->putfunc = memory_putfunc;
# 1207|-> 	priv->data = NULL;
# 1208|   	priv->size = 0;
# 1209|   	priv->curoff = 0;

Error: CPPCHECK_WARNING (CWE-476): [#def130]
libmtp-1.1.22/src/libusb1-glue.c:1208: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: priv
# 1206|   	handler->putfunc = memory_putfunc;
# 1207|   	priv->data = NULL;
# 1208|-> 	priv->size = 0;
# 1209|   	priv->curoff = 0;
# 1210|   	return PTP_RC_OK;

Error: CPPCHECK_WARNING (CWE-476): [#def131]
libmtp-1.1.22/src/libusb1-glue.c:1209: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: priv
# 1207|   	priv->data = NULL;
# 1208|   	priv->size = 0;
# 1209|-> 	priv->curoff = 0;
# 1210|   	return PTP_RC_OK;
# 1211|   }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def132]
libmtp-1.1.22/src/libusb1-glue.c:1823:13: warning[-Wanalyzer-malloc-leak]: leak of 'data'
libmtp-1.1.22/src/libusb1-glue.c:1808:12: branch_false: following 'false' branch (when 'params' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:1812:20: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1813:12: branch_false: following 'false' branch (when 'usbevent' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:1817:16: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1817:16: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:1818:12: branch_false: following 'false' branch (when 'data' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:1823:13: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1823:13: throw: if 'libusb_alloc_transfer' throws an exception...
libmtp-1.1.22/src/libusb1-glue.c:1823:13: danger: 'data' leaks here; was allocated at [(5)](sarif:/runs/0/results/33/codeFlows/0/threadFlows/0/locations/4)
# 1821|   	}
# 1822|   
# 1823|-> 	t = libusb_alloc_transfer(0);
# 1824|   	if (t == NULL) {
# 1825|   		free(data);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def133]
libmtp-1.1.22/src/libusb1-glue.c:1823:13: warning[-Wanalyzer-malloc-leak]: leak of 'usbevent'
libmtp-1.1.22/src/libusb1-glue.c:1808:12: branch_false: following 'false' branch (when 'params' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:1812:20: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1812:20: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:1813:12: branch_false: following 'false' branch (when 'usbevent' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:1817:16: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1818:12: branch_false: following 'false' branch (when 'data' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:1823:13: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:1823:13: throw: if 'libusb_alloc_transfer' throws an exception...
libmtp-1.1.22/src/libusb1-glue.c:1823:13: danger: 'usbevent' leaks here; was allocated at [(3)](sarif:/runs/0/results/34/codeFlows/0/threadFlows/0/locations/2)
# 1821|   	}
# 1822|   
# 1823|-> 	t = libusb_alloc_transfer(0);
# 1824|   	if (t == NULL) {
# 1825|   		free(data);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def134]
libmtp-1.1.22/src/libusb1-glue.c:2132:9: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2275:9: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2275:9: call_function: calling 'find_interface_and_endpoints' from 'configure_usb_device'
# 2130|     struct libusb_device_descriptor desc;
# 2131|   
# 2132|->   ret = libusb_get_device_descriptor(dev, &desc);
# 2133|     if (ret != LIBUSB_SUCCESS)
# 2134|       return -1;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def135]
libmtp-1.1.22/src/libusb1-glue.c:2141:11: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2275:9: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2275:9: call_function: calling 'find_interface_and_endpoints' from 'configure_usb_device'
# 2139|       struct libusb_config_descriptor *config;
# 2140|   
# 2141|->     ret = libusb_get_config_descriptor(dev, i, &config);
# 2142|       if (ret != LIBUSB_SUCCESS)
# 2143|         continue;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def136]
libmtp-1.1.22/src/libusb1-glue.c:2199:5: warning[-Wanalyzer-malloc-leak]: leak of 'ptp_usb'
libmtp-1.1.22/src/libusb1-glue.c:2212:23: enter_function: entry to 'configure_usb_device'
libmtp-1.1.22/src/libusb1-glue.c:2227:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2230:14: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2231:15: branch_true: following 'true' branch...
libmtp-1.1.22/src/libusb1-glue.c:2232:35: branch_true: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2254:25: acquire_memory: allocated here
libmtp-1.1.22/src/libusb1-glue.c:2255:6: branch_false: following 'false' branch (when 'ptp_usb' is non-NULL)...
libmtp-1.1.22/src/libusb1-glue.c:2260:3: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2269:6: branch_false: following 'false' branch...
libmtp-1.1.22/src/libusb1-glue.c:2275:9: branch_false: ...to here
libmtp-1.1.22/src/libusb1-glue.c:2275:9: call_function: calling 'find_interface_and_endpoints' from 'configure_usb_device'
# 2197|         } // Next altsetting
# 2198|       } // Next interface
# 2199|->     libusb_free_config_descriptor(config);
# 2200|     } // Next config
# 2201|     return -1;

Error: CPPCHECK_WARNING (CWE-476): [#def137]
libmtp-1.1.22/src/mtpz.c:88: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: result
#   86|   	*str = (char*)malloc(num);
#   87|   	char* result = *str;
#   88|-> 	if (fgets(result, num, stream) != NULL)
#   89|   	{
#   90|   		size_t newlen = strlen(result);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def138]
libmtp-1.1.22/src/mtpz.c:304:9: warning[-Wanalyzer-malloc-leak]: leak of 'message'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  302|   	gcry_mpi_t mpi_modulus, mpi_privkey, mpi_pubexp;
#  303|   
#  304|-> 	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|   	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def139]
libmtp-1.1.22/src/mtpz.c:304:9: warning[-Wanalyzer-malloc-leak]: leak of 'msg_dec'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  302|   	gcry_mpi_t mpi_modulus, mpi_privkey, mpi_pubexp;
#  303|   
#  304|-> 	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|   	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def140]
libmtp-1.1.22/src/mtpz.c:304:9: warning[-Wanalyzer-malloc-leak]: leak of 'rsa'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  302|   	gcry_mpi_t mpi_modulus, mpi_privkey, mpi_pubexp;
#  303|   
#  304|-> 	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|   	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def141]
libmtp-1.1.22/src/mtpz.c:305:9: warning[-Wanalyzer-malloc-leak]: leak of 'message'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  303|   
#  304|   	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|-> 	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def142]
libmtp-1.1.22/src/mtpz.c:305:9: warning[-Wanalyzer-malloc-leak]: leak of 'msg_dec'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  303|   
#  304|   	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|-> 	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def143]
libmtp-1.1.22/src/mtpz.c:305:9: warning[-Wanalyzer-malloc-leak]: leak of 'rsa'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  303|   
#  304|   	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|-> 	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def144]
libmtp-1.1.22/src/mtpz.c:306:9: warning[-Wanalyzer-malloc-leak]: leak of 'message'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  304|   	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|   	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|-> 	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   
#  308|   	gcry_sexp_build(&rsa->privkey, NULL, "(private-key (rsa (n %m) (e %m) (d %m)))", mpi_modulus, mpi_pubexp, mpi_privkey);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def145]
libmtp-1.1.22/src/mtpz.c:306:9: warning[-Wanalyzer-malloc-leak]: leak of 'msg_dec'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  304|   	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|   	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|-> 	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   
#  308|   	gcry_sexp_build(&rsa->privkey, NULL, "(private-key (rsa (n %m) (e %m) (d %m)))", mpi_modulus, mpi_pubexp, mpi_privkey);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def146]
libmtp-1.1.22/src/mtpz.c:306:9: warning[-Wanalyzer-malloc-leak]: leak of 'rsa'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  304|   	gcry_mpi_scan(&mpi_modulus, GCRYMPI_FMT_HEX, str_modulus, 0, NULL);
#  305|   	gcry_mpi_scan(&mpi_privkey, GCRYMPI_FMT_HEX, str_privkey, 0, NULL);
#  306|-> 	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   
#  308|   	gcry_sexp_build(&rsa->privkey, NULL, "(private-key (rsa (n %m) (e %m) (d %m)))", mpi_modulus, mpi_pubexp, mpi_privkey);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def147]
libmtp-1.1.22/src/mtpz.c:308:9: warning[-Wanalyzer-malloc-leak]: leak of 'message'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   
#  308|-> 	gcry_sexp_build(&rsa->privkey, NULL, "(private-key (rsa (n %m) (e %m) (d %m)))", mpi_modulus, mpi_pubexp, mpi_privkey);
#  309|   	gcry_sexp_build(&rsa->pubkey, NULL, "(public-key (rsa (n %m) (e %m)))", mpi_modulus, mpi_pubexp);
#  310|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def148]
libmtp-1.1.22/src/mtpz.c:308:9: warning[-Wanalyzer-malloc-leak]: leak of 'msg_dec'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   
#  308|-> 	gcry_sexp_build(&rsa->privkey, NULL, "(private-key (rsa (n %m) (e %m) (d %m)))", mpi_modulus, mpi_pubexp, mpi_privkey);
#  309|   	gcry_sexp_build(&rsa->pubkey, NULL, "(public-key (rsa (n %m) (e %m)))", mpi_modulus, mpi_pubexp);
#  310|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def149]
libmtp-1.1.22/src/mtpz.c:308:9: warning[-Wanalyzer-malloc-leak]: leak of 'rsa'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  306|   	gcry_mpi_scan(&mpi_pubexp, GCRYMPI_FMT_HEX, str_pubexp, 0, NULL);
#  307|   
#  308|-> 	gcry_sexp_build(&rsa->privkey, NULL, "(private-key (rsa (n %m) (e %m) (d %m)))", mpi_modulus, mpi_pubexp, mpi_privkey);
#  309|   	gcry_sexp_build(&rsa->pubkey, NULL, "(public-key (rsa (n %m) (e %m)))", mpi_modulus, mpi_pubexp);
#  310|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def150]
libmtp-1.1.22/src/mtpz.c:309:9: warning[-Wanalyzer-malloc-leak]: leak of 'message'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  307|   
#  308|   	gcry_sexp_build(&rsa->privkey, NULL, "(private-key (rsa (n %m) (e %m) (d %m)))", mpi_modulus, mpi_pubexp, mpi_privkey);
#  309|-> 	gcry_sexp_build(&rsa->pubkey, NULL, "(public-key (rsa (n %m) (e %m)))", mpi_modulus, mpi_pubexp);
#  310|   
#  311|   	gcry_mpi_release(mpi_modulus);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def151]
libmtp-1.1.22/src/mtpz.c:309:9: warning[-Wanalyzer-malloc-leak]: leak of 'msg_dec'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  307|   
#  308|   	gcry_sexp_build(&rsa->privkey, NULL, "(private-key (rsa (n %m) (e %m) (d %m)))", mpi_modulus, mpi_pubexp, mpi_privkey);
#  309|-> 	gcry_sexp_build(&rsa->pubkey, NULL, "(public-key (rsa (n %m) (e %m)))", mpi_modulus, mpi_pubexp);
#  310|   
#  311|   	gcry_mpi_release(mpi_modulus);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def152]
libmtp-1.1.22/src/mtpz.c:311:9: warning[-Wanalyzer-malloc-leak]: leak of 'message'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  309|   	gcry_sexp_build(&rsa->pubkey, NULL, "(public-key (rsa (n %m) (e %m)))", mpi_modulus, mpi_pubexp);
#  310|   
#  311|-> 	gcry_mpi_release(mpi_modulus);
#  312|   	gcry_mpi_release(mpi_privkey);
#  313|   	gcry_mpi_release(mpi_pubexp);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def153]
libmtp-1.1.22/src/mtpz.c:311:9: warning[-Wanalyzer-malloc-leak]: leak of 'msg_dec'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  309|   	gcry_sexp_build(&rsa->pubkey, NULL, "(public-key (rsa (n %m) (e %m)))", mpi_modulus, mpi_pubexp);
#  310|   
#  311|-> 	gcry_mpi_release(mpi_modulus);
#  312|   	gcry_mpi_release(mpi_privkey);
#  313|   	gcry_mpi_release(mpi_pubexp);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def154]
libmtp-1.1.22/src/mtpz.c:312:9: warning[-Wanalyzer-malloc-leak]: leak of 'message'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  310|   
#  311|   	gcry_mpi_release(mpi_modulus);
#  312|-> 	gcry_mpi_release(mpi_privkey);
#  313|   	gcry_mpi_release(mpi_pubexp);
#  314|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def155]
libmtp-1.1.22/src/mtpz.c:312:9: warning[-Wanalyzer-malloc-leak]: leak of 'msg_dec'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  310|   
#  311|   	gcry_mpi_release(mpi_modulus);
#  312|-> 	gcry_mpi_release(mpi_privkey);
#  313|   	gcry_mpi_release(mpi_pubexp);
#  314|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def156]
libmtp-1.1.22/src/mtpz.c:313:9: warning[-Wanalyzer-malloc-leak]: leak of 'message'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  311|   	gcry_mpi_release(mpi_modulus);
#  312|   	gcry_mpi_release(mpi_privkey);
#  313|-> 	gcry_mpi_release(mpi_pubexp);
#  314|   
#  315|   	return rsa;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def157]
libmtp-1.1.22/src/mtpz.c:313:9: warning[-Wanalyzer-malloc-leak]: leak of 'msg_dec'
libmtp-1.1.22/src/mtpz.c:1533:1: enter_function: entry to 'ptp_mtpz_validatehandshakeresponse'
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: allocated here
libmtp-1.1.22/src/mtpz.c:1574:27: call_function: calling 'mtpz_rsa_init' from 'ptp_mtpz_validatehandshakeresponse'
#  311|   	gcry_mpi_release(mpi_modulus);
#  312|   	gcry_mpi_release(mpi_privkey);
#  313|-> 	gcry_mpi_release(mpi_pubexp);
#  314|   
#  315|   	return rsa;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def158]
libmtp-1.1.22/src/mtpz.c:386:9: warning[-Wanalyzer-null-dereference]: dereference of NULL 'mtpz_hash_init_state()'
libmtp-1.1.22/src/mtpz.c:1695:1: enter_function: entry to 'ptp_mtpz_makeapplicationcertificatemessage'
libmtp-1.1.22/src/mtpz.c:1723:21: branch_true: following 'true' branch (when 'i != 16')...
libmtp-1.1.22/src/mtpz.c:1724:49: branch_true: ...to here
libmtp-1.1.22/src/mtpz.c:1723:21: branch_true: following 'true' branch (when 'i != 16')...
libmtp-1.1.22/src/mtpz.c:1724:49: branch_true: ...to here
libmtp-1.1.22/src/mtpz.c:1730:23: call_function: calling 'mtpz_hash_init_state' from 'ptp_mtpz_makeapplicationcertificatemessage'
libmtp-1.1.22/src/mtpz.c:1730:23: return_function: returning to 'ptp_mtpz_makeapplicationcertificatemessage' from 'mtpz_hash_init_state'
libmtp-1.1.22/src/mtpz.c:1735:9: call_function: inlined call to 'mtpz_hash_reset_state' from 'ptp_mtpz_makeapplicationcertificatemessage'
#  384|   	 * Page 13, section 5.3.1
#  385|   	 */
#  386|-> 	state_box[0] = 0x67452301;
#  387|   	state_box[1] = 0xefcdab89;
#  388|   	state_box[2] = 0x98badcfe;

Error: CPPCHECK_WARNING (CWE-682): [#def159]
libmtp-1.1.22/src/mtpz.c:428: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  426|   	while (i > 63)
#  427|   	{
#  428|-> 		mtpz_hash_compute_hash(state, msg + j, 64);
#  429|   		j += 64;
#  430|   		i -= 64;

Error: CPPCHECK_WARNING (CWE-476): [#def160]
libmtp-1.1.22/src/mtpz.c:454: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: v5
#  452|   
#  453|   	char *v5 = (char *)malloc(72);
#  454|-> 	memset(v5, 0, 72);
#  455|   
#  456|   	v5[0] = '\x80';

Error: CPPCHECK_WARNING (CWE-476): [#def161]
libmtp-1.1.22/src/mtpz.c:456: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: v5
#  454|   	memset(v5, 0, 72);
#  455|   
#  456|-> 	v5[0] = '\x80';
#  457|   	v6 = 8 * state_box[MTPZ_HASHSTATE_84] | (state_box[MTPZ_HASHSTATE_88] >> 29);
#  458|   	v7 = 8 * state_box[MTPZ_HASHSTATE_88];

Error: CPPCHECK_WARNING (CWE-682): [#def162]
libmtp-1.1.22/src/mtpz.c:463: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  461|   	v7 = MTPZ_SWAP(v7);
#  462|   
#  463|-> 	*(int *)(v5 + v2 - 8) = v6;
#  464|   	*(int *)(v5 + v2 - 4) = v7;
#  465|   

Error: CPPCHECK_WARNING (CWE-682): [#def163]
libmtp-1.1.22/src/mtpz.c:464: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  462|   
#  463|   	*(int *)(v5 + v2 - 8) = v6;
#  464|-> 	*(int *)(v5 + v2 - 4) = v7;
#  465|   
#  466|   	mtpz_hash_transform_hash(state, v5, v2);

Error: CPPCHECK_WARNING (CWE-476): [#def164]
libmtp-1.1.22/src/mtpz.c:469: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  467|   
#  468|   	int *out_int = (int *)out;
#  469|-> 	out_int[0] = MTPZ_SWAP(state_box[0]);
#  470|   	out_int[1] = MTPZ_SWAP(state_box[1]);
#  471|   	out_int[2] = MTPZ_SWAP(state_box[2]);

Error: CPPCHECK_WARNING (CWE-476): [#def165]
libmtp-1.1.22/src/mtpz.c:470: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  468|   	int *out_int = (int *)out;
#  469|   	out_int[0] = MTPZ_SWAP(state_box[0]);
#  470|-> 	out_int[1] = MTPZ_SWAP(state_box[1]);
#  471|   	out_int[2] = MTPZ_SWAP(state_box[2]);
#  472|   	out_int[3] = MTPZ_SWAP(state_box[3]);

Error: CPPCHECK_WARNING (CWE-476): [#def166]
libmtp-1.1.22/src/mtpz.c:471: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  469|   	out_int[0] = MTPZ_SWAP(state_box[0]);
#  470|   	out_int[1] = MTPZ_SWAP(state_box[1]);
#  471|-> 	out_int[2] = MTPZ_SWAP(state_box[2]);
#  472|   	out_int[3] = MTPZ_SWAP(state_box[3]);
#  473|   	out_int[4] = MTPZ_SWAP(state_box[4]);

Error: CPPCHECK_WARNING (CWE-476): [#def167]
libmtp-1.1.22/src/mtpz.c:472: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  470|   	out_int[1] = MTPZ_SWAP(state_box[1]);
#  471|   	out_int[2] = MTPZ_SWAP(state_box[2]);
#  472|-> 	out_int[3] = MTPZ_SWAP(state_box[3]);
#  473|   	out_int[4] = MTPZ_SWAP(state_box[4]);
#  474|   

Error: CPPCHECK_WARNING (CWE-476): [#def168]
libmtp-1.1.22/src/mtpz.c:473: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  471|   	out_int[2] = MTPZ_SWAP(state_box[2]);
#  472|   	out_int[3] = MTPZ_SWAP(state_box[3]);
#  473|-> 	out_int[4] = MTPZ_SWAP(state_box[4]);
#  474|   
#  475|   	memset(state, 0, 64);

Error: CPPCHECK_WARNING (CWE-476): [#def169]
libmtp-1.1.22/src/mtpz.c:487: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: v13
#  485|   	int k;
#  486|   
#  487|-> 	memset(v13, 0, v11 * 20);
#  488|   	memset(v5, 0, len + 4);
#  489|   	memcpy(v5, msg, len);

Error: CPPCHECK_WARNING (CWE-476): [#def170]
libmtp-1.1.22/src/mtpz.c:488: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: v5
#  486|   
#  487|   	memset(v13, 0, v11 * 20);
#  488|-> 	memset(v5, 0, len + 4);
#  489|   	memcpy(v5, msg, len);
#  490|   

Error: CPPCHECK_WARNING (CWE-476): [#def171]
libmtp-1.1.22/src/mtpz.c:489: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: msg
#  487|   	memset(v13, 0, v11 * 20);
#  488|   	memset(v5, 0, len + 4);
#  489|-> 	memcpy(v5, msg, len);
#  490|   
#  491|   	for (i = 0; i < v11; i++)

Error: CPPCHECK_WARNING (CWE-476): [#def172]
libmtp-1.1.22/src/mtpz.c:489: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: v5
#  487|   	memset(v13, 0, v11 * 20);
#  488|   	memset(v5, 0, len + 4);
#  489|-> 	memcpy(v5, msg, len);
#  490|   
#  491|   	for (i = 0; i < v11; i++)

Error: CPPCHECK_WARNING (CWE-682): [#def173]
libmtp-1.1.22/src/mtpz.c:494: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  492|   	{
#  493|   		k = MTPZ_SWAP(i);
#  494|-> 		*(int *)(v5 + len) = k;
#  495|   
#  496|   		mtpz_hash_reset_state(state);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def174]
libmtp-1.1.22/src/mtpz.c:617:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'dtf' where non-null expected
libmtp-1.1.22/src/mtpz.c:605:6: enter_function: entry to 'mtpz_encryption_cipher_advanced'
libmtp-1.1.22/src/mtpz.c:610:35: call_function: calling 'mtpz_encryption_expand_key' from 'mtpz_encryption_cipher_advanced'
libmtp-1.1.22/src/mtpz.c:610:35: return_function: returning to 'mtpz_encryption_cipher_advanced' from 'mtpz_encryption_expand_key'
libmtp-1.1.22/src/mtpz.c:616:45: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:617:9: danger: argument 1 ('dtf') from [(15)](sarif:/runs/0/results/21/codeFlows/0/threadFlows/0/locations/14) could be NULL where non-null expected
#  615|   	unsigned int *data_int = (unsigned int *)data;
#  616|   	unsigned int *dtf = (unsigned int *)malloc(16);
#  617|-> 	memset((unsigned char *)dtf, 0, 16);
#  618|   
#  619|   	while (count != 0)

Error: CPPCHECK_WARNING (CWE-682): [#def175]
libmtp-1.1.22/src/mtpz.c:629: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  627|   		}
#  628|   
#  629|-> 		memcpy(out, data + offset, chunk);
#  630|   
#  631|   		if (encrypt)

Error: CPPCHECK_WARNING (CWE-476): [#def176]
libmtp-1.1.22/src/mtpz.c:629: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out
#  627|   		}
#  628|   
#  629|-> 		memcpy(out, data + offset, chunk);
#  630|   
#  631|   		if (encrypt)

Error: CPPCHECK_WARNING (CWE-476): [#def177]
libmtp-1.1.22/src/mtpz.c:633: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  631|   		if (encrypt)
#  632|   		{
#  633|-> 			out_int[0] ^= MTPZ_SWAP(dtf[0]);
#  634|   			out_int[1] ^= MTPZ_SWAP(dtf[1]);
#  635|   			out_int[2] ^= MTPZ_SWAP(dtf[2]);

Error: CPPCHECK_WARNING (CWE-476): [#def178]
libmtp-1.1.22/src/mtpz.c:633: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  631|   		if (encrypt)
#  632|   		{
#  633|-> 			out_int[0] ^= MTPZ_SWAP(dtf[0]);
#  634|   			out_int[1] ^= MTPZ_SWAP(dtf[1]);
#  635|   			out_int[2] ^= MTPZ_SWAP(dtf[2]);

Error: CPPCHECK_WARNING (CWE-476): [#def179]
libmtp-1.1.22/src/mtpz.c:634: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  632|   		{
#  633|   			out_int[0] ^= MTPZ_SWAP(dtf[0]);
#  634|-> 			out_int[1] ^= MTPZ_SWAP(dtf[1]);
#  635|   			out_int[2] ^= MTPZ_SWAP(dtf[2]);
#  636|   			out_int[3] ^= MTPZ_SWAP(dtf[3]);

Error: CPPCHECK_WARNING (CWE-476): [#def180]
libmtp-1.1.22/src/mtpz.c:634: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  632|   		{
#  633|   			out_int[0] ^= MTPZ_SWAP(dtf[0]);
#  634|-> 			out_int[1] ^= MTPZ_SWAP(dtf[1]);
#  635|   			out_int[2] ^= MTPZ_SWAP(dtf[2]);
#  636|   			out_int[3] ^= MTPZ_SWAP(dtf[3]);

Error: CPPCHECK_WARNING (CWE-476): [#def181]
libmtp-1.1.22/src/mtpz.c:635: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  633|   			out_int[0] ^= MTPZ_SWAP(dtf[0]);
#  634|   			out_int[1] ^= MTPZ_SWAP(dtf[1]);
#  635|-> 			out_int[2] ^= MTPZ_SWAP(dtf[2]);
#  636|   			out_int[3] ^= MTPZ_SWAP(dtf[3]);
#  637|   

Error: CPPCHECK_WARNING (CWE-476): [#def182]
libmtp-1.1.22/src/mtpz.c:635: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  633|   			out_int[0] ^= MTPZ_SWAP(dtf[0]);
#  634|   			out_int[1] ^= MTPZ_SWAP(dtf[1]);
#  635|-> 			out_int[2] ^= MTPZ_SWAP(dtf[2]);
#  636|   			out_int[3] ^= MTPZ_SWAP(dtf[3]);
#  637|   

Error: CPPCHECK_WARNING (CWE-476): [#def183]
libmtp-1.1.22/src/mtpz.c:636: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  634|   			out_int[1] ^= MTPZ_SWAP(dtf[1]);
#  635|   			out_int[2] ^= MTPZ_SWAP(dtf[2]);
#  636|-> 			out_int[3] ^= MTPZ_SWAP(dtf[3]);
#  637|   
#  638|   			mtpz_encryption_encrypt_custom(data + offset, out, expanded);

Error: CPPCHECK_WARNING (CWE-476): [#def184]
libmtp-1.1.22/src/mtpz.c:636: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  634|   			out_int[1] ^= MTPZ_SWAP(dtf[1]);
#  635|   			out_int[2] ^= MTPZ_SWAP(dtf[2]);
#  636|-> 			out_int[3] ^= MTPZ_SWAP(dtf[3]);
#  637|   
#  638|   			mtpz_encryption_encrypt_custom(data + offset, out, expanded);

Error: CPPCHECK_WARNING (CWE-682): [#def185]
libmtp-1.1.22/src/mtpz.c:638: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  636|   			out_int[3] ^= MTPZ_SWAP(dtf[3]);
#  637|   
#  638|-> 			mtpz_encryption_encrypt_custom(data + offset, out, expanded);
#  639|   
#  640|   			dtf[0] = MTPZ_SWAP(data_int[(offset / 4) + 0]);

Error: CPPCHECK_WARNING (CWE-476): [#def186]
libmtp-1.1.22/src/mtpz.c:640: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data_int
#  638|   			mtpz_encryption_encrypt_custom(data + offset, out, expanded);
#  639|   
#  640|-> 			dtf[0] = MTPZ_SWAP(data_int[(offset / 4) + 0]);
#  641|   			dtf[1] = MTPZ_SWAP(data_int[(offset / 4) + 1]);
#  642|   			dtf[2] = MTPZ_SWAP(data_int[(offset / 4) + 2]);

Error: CPPCHECK_WARNING (CWE-476): [#def187]
libmtp-1.1.22/src/mtpz.c:640: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  638|   			mtpz_encryption_encrypt_custom(data + offset, out, expanded);
#  639|   
#  640|-> 			dtf[0] = MTPZ_SWAP(data_int[(offset / 4) + 0]);
#  641|   			dtf[1] = MTPZ_SWAP(data_int[(offset / 4) + 1]);
#  642|   			dtf[2] = MTPZ_SWAP(data_int[(offset / 4) + 2]);

Error: CPPCHECK_WARNING (CWE-476): [#def188]
libmtp-1.1.22/src/mtpz.c:641: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data_int
#  639|   
#  640|   			dtf[0] = MTPZ_SWAP(data_int[(offset / 4) + 0]);
#  641|-> 			dtf[1] = MTPZ_SWAP(data_int[(offset / 4) + 1]);
#  642|   			dtf[2] = MTPZ_SWAP(data_int[(offset / 4) + 2]);
#  643|   			dtf[3] = MTPZ_SWAP(data_int[(offset / 4) + 3]);

Error: CPPCHECK_WARNING (CWE-476): [#def189]
libmtp-1.1.22/src/mtpz.c:641: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  639|   
#  640|   			dtf[0] = MTPZ_SWAP(data_int[(offset / 4) + 0]);
#  641|-> 			dtf[1] = MTPZ_SWAP(data_int[(offset / 4) + 1]);
#  642|   			dtf[2] = MTPZ_SWAP(data_int[(offset / 4) + 2]);
#  643|   			dtf[3] = MTPZ_SWAP(data_int[(offset / 4) + 3]);

Error: CPPCHECK_WARNING (CWE-476): [#def190]
libmtp-1.1.22/src/mtpz.c:642: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data_int
#  640|   			dtf[0] = MTPZ_SWAP(data_int[(offset / 4) + 0]);
#  641|   			dtf[1] = MTPZ_SWAP(data_int[(offset / 4) + 1]);
#  642|-> 			dtf[2] = MTPZ_SWAP(data_int[(offset / 4) + 2]);
#  643|   			dtf[3] = MTPZ_SWAP(data_int[(offset / 4) + 3]);
#  644|   		}

Error: CPPCHECK_WARNING (CWE-476): [#def191]
libmtp-1.1.22/src/mtpz.c:642: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  640|   			dtf[0] = MTPZ_SWAP(data_int[(offset / 4) + 0]);
#  641|   			dtf[1] = MTPZ_SWAP(data_int[(offset / 4) + 1]);
#  642|-> 			dtf[2] = MTPZ_SWAP(data_int[(offset / 4) + 2]);
#  643|   			dtf[3] = MTPZ_SWAP(data_int[(offset / 4) + 3]);
#  644|   		}

Error: CPPCHECK_WARNING (CWE-476): [#def192]
libmtp-1.1.22/src/mtpz.c:643: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data_int
#  641|   			dtf[1] = MTPZ_SWAP(data_int[(offset / 4) + 1]);
#  642|   			dtf[2] = MTPZ_SWAP(data_int[(offset / 4) + 2]);
#  643|-> 			dtf[3] = MTPZ_SWAP(data_int[(offset / 4) + 3]);
#  644|   		}
#  645|   		else

Error: CPPCHECK_WARNING (CWE-476): [#def193]
libmtp-1.1.22/src/mtpz.c:643: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  641|   			dtf[1] = MTPZ_SWAP(data_int[(offset / 4) + 1]);
#  642|   			dtf[2] = MTPZ_SWAP(data_int[(offset / 4) + 2]);
#  643|-> 			dtf[3] = MTPZ_SWAP(data_int[(offset / 4) + 3]);
#  644|   		}
#  645|   		else

Error: CPPCHECK_WARNING (CWE-682): [#def194]
libmtp-1.1.22/src/mtpz.c:647: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  645|   		else
#  646|   		{
#  647|-> 			mtpz_encryption_decrypt_custom(data + offset, out, expanded);
#  648|   
#  649|   			data_int[(offset / 4) + 0] ^= MTPZ_SWAP(dtf[0]);

Error: CPPCHECK_WARNING (CWE-476): [#def195]
libmtp-1.1.22/src/mtpz.c:649: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data_int
#  647|   			mtpz_encryption_decrypt_custom(data + offset, out, expanded);
#  648|   
#  649|-> 			data_int[(offset / 4) + 0] ^= MTPZ_SWAP(dtf[0]);
#  650|   			data_int[(offset / 4) + 1] ^= MTPZ_SWAP(dtf[1]);
#  651|   			data_int[(offset / 4) + 2] ^= MTPZ_SWAP(dtf[2]);

Error: CPPCHECK_WARNING (CWE-476): [#def196]
libmtp-1.1.22/src/mtpz.c:649: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  647|   			mtpz_encryption_decrypt_custom(data + offset, out, expanded);
#  648|   
#  649|-> 			data_int[(offset / 4) + 0] ^= MTPZ_SWAP(dtf[0]);
#  650|   			data_int[(offset / 4) + 1] ^= MTPZ_SWAP(dtf[1]);
#  651|   			data_int[(offset / 4) + 2] ^= MTPZ_SWAP(dtf[2]);

Error: CPPCHECK_WARNING (CWE-476): [#def197]
libmtp-1.1.22/src/mtpz.c:650: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data_int
#  648|   
#  649|   			data_int[(offset / 4) + 0] ^= MTPZ_SWAP(dtf[0]);
#  650|-> 			data_int[(offset / 4) + 1] ^= MTPZ_SWAP(dtf[1]);
#  651|   			data_int[(offset / 4) + 2] ^= MTPZ_SWAP(dtf[2]);
#  652|   			data_int[(offset / 4) + 3] ^= MTPZ_SWAP(dtf[3]);

Error: CPPCHECK_WARNING (CWE-476): [#def198]
libmtp-1.1.22/src/mtpz.c:650: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  648|   
#  649|   			data_int[(offset / 4) + 0] ^= MTPZ_SWAP(dtf[0]);
#  650|-> 			data_int[(offset / 4) + 1] ^= MTPZ_SWAP(dtf[1]);
#  651|   			data_int[(offset / 4) + 2] ^= MTPZ_SWAP(dtf[2]);
#  652|   			data_int[(offset / 4) + 3] ^= MTPZ_SWAP(dtf[3]);

Error: CPPCHECK_WARNING (CWE-476): [#def199]
libmtp-1.1.22/src/mtpz.c:651: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data_int
#  649|   			data_int[(offset / 4) + 0] ^= MTPZ_SWAP(dtf[0]);
#  650|   			data_int[(offset / 4) + 1] ^= MTPZ_SWAP(dtf[1]);
#  651|-> 			data_int[(offset / 4) + 2] ^= MTPZ_SWAP(dtf[2]);
#  652|   			data_int[(offset / 4) + 3] ^= MTPZ_SWAP(dtf[3]);
#  653|   

Error: CPPCHECK_WARNING (CWE-476): [#def200]
libmtp-1.1.22/src/mtpz.c:651: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  649|   			data_int[(offset / 4) + 0] ^= MTPZ_SWAP(dtf[0]);
#  650|   			data_int[(offset / 4) + 1] ^= MTPZ_SWAP(dtf[1]);
#  651|-> 			data_int[(offset / 4) + 2] ^= MTPZ_SWAP(dtf[2]);
#  652|   			data_int[(offset / 4) + 3] ^= MTPZ_SWAP(dtf[3]);
#  653|   

Error: CPPCHECK_WARNING (CWE-476): [#def201]
libmtp-1.1.22/src/mtpz.c:652: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: data_int
#  650|   			data_int[(offset / 4) + 1] ^= MTPZ_SWAP(dtf[1]);
#  651|   			data_int[(offset / 4) + 2] ^= MTPZ_SWAP(dtf[2]);
#  652|-> 			data_int[(offset / 4) + 3] ^= MTPZ_SWAP(dtf[3]);
#  653|   
#  654|   			dtf[0] = MTPZ_SWAP(out_int[0]);

Error: CPPCHECK_WARNING (CWE-476): [#def202]
libmtp-1.1.22/src/mtpz.c:652: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  650|   			data_int[(offset / 4) + 1] ^= MTPZ_SWAP(dtf[1]);
#  651|   			data_int[(offset / 4) + 2] ^= MTPZ_SWAP(dtf[2]);
#  652|-> 			data_int[(offset / 4) + 3] ^= MTPZ_SWAP(dtf[3]);
#  653|   
#  654|   			dtf[0] = MTPZ_SWAP(out_int[0]);

Error: CPPCHECK_WARNING (CWE-476): [#def203]
libmtp-1.1.22/src/mtpz.c:654: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  652|   			data_int[(offset / 4) + 3] ^= MTPZ_SWAP(dtf[3]);
#  653|   
#  654|-> 			dtf[0] = MTPZ_SWAP(out_int[0]);
#  655|   			dtf[1] = MTPZ_SWAP(out_int[1]);
#  656|   			dtf[2] = MTPZ_SWAP(out_int[2]);

Error: CPPCHECK_WARNING (CWE-476): [#def204]
libmtp-1.1.22/src/mtpz.c:654: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  652|   			data_int[(offset / 4) + 3] ^= MTPZ_SWAP(dtf[3]);
#  653|   
#  654|-> 			dtf[0] = MTPZ_SWAP(out_int[0]);
#  655|   			dtf[1] = MTPZ_SWAP(out_int[1]);
#  656|   			dtf[2] = MTPZ_SWAP(out_int[2]);

Error: CPPCHECK_WARNING (CWE-476): [#def205]
libmtp-1.1.22/src/mtpz.c:655: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  653|   
#  654|   			dtf[0] = MTPZ_SWAP(out_int[0]);
#  655|-> 			dtf[1] = MTPZ_SWAP(out_int[1]);
#  656|   			dtf[2] = MTPZ_SWAP(out_int[2]);
#  657|   			dtf[3] = MTPZ_SWAP(out_int[3]);

Error: CPPCHECK_WARNING (CWE-476): [#def206]
libmtp-1.1.22/src/mtpz.c:655: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  653|   
#  654|   			dtf[0] = MTPZ_SWAP(out_int[0]);
#  655|-> 			dtf[1] = MTPZ_SWAP(out_int[1]);
#  656|   			dtf[2] = MTPZ_SWAP(out_int[2]);
#  657|   			dtf[3] = MTPZ_SWAP(out_int[3]);

Error: CPPCHECK_WARNING (CWE-476): [#def207]
libmtp-1.1.22/src/mtpz.c:656: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  654|   			dtf[0] = MTPZ_SWAP(out_int[0]);
#  655|   			dtf[1] = MTPZ_SWAP(out_int[1]);
#  656|-> 			dtf[2] = MTPZ_SWAP(out_int[2]);
#  657|   			dtf[3] = MTPZ_SWAP(out_int[3]);
#  658|   		}

Error: CPPCHECK_WARNING (CWE-476): [#def208]
libmtp-1.1.22/src/mtpz.c:656: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  654|   			dtf[0] = MTPZ_SWAP(out_int[0]);
#  655|   			dtf[1] = MTPZ_SWAP(out_int[1]);
#  656|-> 			dtf[2] = MTPZ_SWAP(out_int[2]);
#  657|   			dtf[3] = MTPZ_SWAP(out_int[3]);
#  658|   		}

Error: CPPCHECK_WARNING (CWE-476): [#def209]
libmtp-1.1.22/src/mtpz.c:657: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: dtf
#  655|   			dtf[1] = MTPZ_SWAP(out_int[1]);
#  656|   			dtf[2] = MTPZ_SWAP(out_int[2]);
#  657|-> 			dtf[3] = MTPZ_SWAP(out_int[3]);
#  658|   		}
#  659|   

Error: CPPCHECK_WARNING (CWE-476): [#def210]
libmtp-1.1.22/src/mtpz.c:657: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: out_int
#  655|   			dtf[1] = MTPZ_SWAP(out_int[1]);
#  656|   			dtf[2] = MTPZ_SWAP(out_int[2]);
#  657|-> 			dtf[3] = MTPZ_SWAP(out_int[3]);
#  658|   		}
#  659|   

Error: CPPCHECK_WARNING (CWE-476): [#def211]
libmtp-1.1.22/src/mtpz.c:674: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: back
#  672|   	int seek = 0;
#  673|   	unsigned char *back = (unsigned char *)malloc(484);
#  674|-> 	memset(back, 0, 484);
#  675|   	*out_len = 484;
#  676|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def212]
libmtp-1.1.22/src/mtpz.c:674:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'back' where non-null expected
libmtp-1.1.22/src/mtpz.c:673:48: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:674:9: danger: argument 1 ('back') from [(1)](sarif:/runs/0/results/22/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
#  672|   	int seek = 0;
#  673|   	unsigned char *back = (unsigned char *)malloc(484);
#  674|-> 	memset(back, 0, 484);
#  675|   	*out_len = 484;
#  676|   

Error: CPPCHECK_WARNING (CWE-476): [#def213]
libmtp-1.1.22/src/mtpz.c:681: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: back
#  679|   	mtpz_encryption_expand_key_inner(constant, key_len, &inner, &inner_len);
#  680|   
#  681|-> 	back[i] = (unsigned char)(count % 0xFF);
#  682|   	i += 4;
#  683|   

Error: CPPCHECK_WARNING (CWE-682): [#def214]
libmtp-1.1.22/src/mtpz.c:684: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  682|   	i += 4;
#  683|   
#  684|-> 	memcpy(back + i, inner, inner_len);
#  685|   	i += inner_len;
#  686|   	memcpy(back + i, inner, inner_len);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def215]
libmtp-1.1.22/src/mtpz.c:684:9: warning[-Wanalyzer-null-argument]: use of NULL 'inner' where non-null expected
libmtp-1.1.22/src/mtpz.c:669:16: enter_function: entry to 'mtpz_encryption_expand_key'
libmtp-1.1.22/src/mtpz.c:679:9: call_function: calling 'mtpz_encryption_expand_key_inner' from 'mtpz_encryption_expand_key'
libmtp-1.1.22/src/mtpz.c:679:9: return_function: returning to 'mtpz_encryption_expand_key' from 'mtpz_encryption_expand_key_inner'
libmtp-1.1.22/src/mtpz.c:684:9: release_memory: 'inner' is NULL
libmtp-1.1.22/src/mtpz.c:684:9: danger: argument 2 ('inner') NULL where non-null expected
#  682|   	i += 4;
#  683|   
#  684|-> 	memcpy(back + i, inner, inner_len);
#  685|   	i += inner_len;
#  686|   	memcpy(back + i, inner, inner_len);

Error: CPPCHECK_WARNING (CWE-682): [#def216]
libmtp-1.1.22/src/mtpz.c:686: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  684|   	memcpy(back + i, inner, inner_len);
#  685|   	i += inner_len;
#  686|-> 	memcpy(back + i, inner, inner_len);
#  687|   	i += inner_len;
#  688|   

Error: CPPCHECK_WARNING (CWE-476): [#def217]
libmtp-1.1.22/src/mtpz.c:738: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: key
#  736|   	unsigned char *key = (unsigned char *)malloc(ks);
#  737|   	unsigned char *temp = (unsigned char *)malloc(4);
#  738|-> 	memcpy(key, constant, key_len);
#  739|   	unsigned char t0, t1, t2, t3;
#  740|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def218]
libmtp-1.1.22/src/mtpz.c:738:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'key' where non-null expected
libmtp-1.1.22/src/mtpz.c:736:47: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:738:9: danger: argument 1 ('key') from [(1)](sarif:/runs/0/results/24/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
#  736|   	unsigned char *key = (unsigned char *)malloc(ks);
#  737|   	unsigned char *temp = (unsigned char *)malloc(4);
#  738|-> 	memcpy(key, constant, key_len);
#  739|   	unsigned char t0, t1, t2, t3;
#  740|   

Error: CPPCHECK_WARNING (CWE-476): [#def219]
libmtp-1.1.22/src/mtpz.c:743: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: key
#  741|   	for (i = key_len; i < ks; i += 4)
#  742|   	{
#  743|-> 		temp[0] = t0 = key[i - 4];
#  744|   		temp[1] = t1 = key[i - 3];
#  745|   		temp[2] = t2 = key[i - 2];

Error: CPPCHECK_WARNING (CWE-476): [#def220]
libmtp-1.1.22/src/mtpz.c:743: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  741|   	for (i = key_len; i < ks; i += 4)
#  742|   	{
#  743|-> 		temp[0] = t0 = key[i - 4];
#  744|   		temp[1] = t1 = key[i - 3];
#  745|   		temp[2] = t2 = key[i - 2];

Error: GCC_ANALYZER_WARNING (CWE-476): [#def221]
libmtp-1.1.22/src/mtpz.c:743:17: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'temp'
libmtp-1.1.22/src/mtpz.c:737:48: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:741:27: branch_true: following 'true' branch (when 'ks > i')...
libmtp-1.1.22/src/mtpz.c:743:36: branch_true: ...to here
libmtp-1.1.22/src/mtpz.c:743:17: danger: 'temp' could be NULL: unchecked value from [(1)](sarif:/runs/0/results/25/codeFlows/0/threadFlows/0/locations/0)
#  741|   	for (i = key_len; i < ks; i += 4)
#  742|   	{
#  743|-> 		temp[0] = t0 = key[i - 4];
#  744|   		temp[1] = t1 = key[i - 3];
#  745|   		temp[2] = t2 = key[i - 2];

Error: CPPCHECK_WARNING (CWE-476): [#def222]
libmtp-1.1.22/src/mtpz.c:744: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: key
#  742|   	{
#  743|   		temp[0] = t0 = key[i - 4];
#  744|-> 		temp[1] = t1 = key[i - 3];
#  745|   		temp[2] = t2 = key[i - 2];
#  746|   		temp[3] = t3 = key[i - 1];

Error: CPPCHECK_WARNING (CWE-476): [#def223]
libmtp-1.1.22/src/mtpz.c:744: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  742|   	{
#  743|   		temp[0] = t0 = key[i - 4];
#  744|-> 		temp[1] = t1 = key[i - 3];
#  745|   		temp[2] = t2 = key[i - 2];
#  746|   		temp[3] = t3 = key[i - 1];

Error: CPPCHECK_WARNING (CWE-476): [#def224]
libmtp-1.1.22/src/mtpz.c:745: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: key
#  743|   		temp[0] = t0 = key[i - 4];
#  744|   		temp[1] = t1 = key[i - 3];
#  745|-> 		temp[2] = t2 = key[i - 2];
#  746|   		temp[3] = t3 = key[i - 1];
#  747|   

Error: CPPCHECK_WARNING (CWE-476): [#def225]
libmtp-1.1.22/src/mtpz.c:745: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  743|   		temp[0] = t0 = key[i - 4];
#  744|   		temp[1] = t1 = key[i - 3];
#  745|-> 		temp[2] = t2 = key[i - 2];
#  746|   		temp[3] = t3 = key[i - 1];
#  747|   

Error: CPPCHECK_WARNING (CWE-476): [#def226]
libmtp-1.1.22/src/mtpz.c:746: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: key
#  744|   		temp[1] = t1 = key[i - 3];
#  745|   		temp[2] = t2 = key[i - 2];
#  746|-> 		temp[3] = t3 = key[i - 1];
#  747|   
#  748|   		if (i % key_len == 0)

Error: CPPCHECK_WARNING (CWE-476): [#def227]
libmtp-1.1.22/src/mtpz.c:746: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  744|   		temp[1] = t1 = key[i - 3];
#  745|   		temp[2] = t2 = key[i - 2];
#  746|-> 		temp[3] = t3 = key[i - 1];
#  747|   
#  748|   		if (i % key_len == 0)

Error: CPPCHECK_WARNING (CWE-476): [#def228]
libmtp-1.1.22/src/mtpz.c:750: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  748|   		if (i % key_len == 0)
#  749|   		{
#  750|-> 			temp[0] = (mtpz_aes_sbox[t1] ^ mtpz_aes_rcon[rcon_i]) & 0xFF;
#  751|   			temp[1] = mtpz_aes_sbox[t2];
#  752|   			temp[2] = mtpz_aes_sbox[t3];

Error: CPPCHECK_WARNING (CWE-476): [#def229]
libmtp-1.1.22/src/mtpz.c:751: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  749|   		{
#  750|   			temp[0] = (mtpz_aes_sbox[t1] ^ mtpz_aes_rcon[rcon_i]) & 0xFF;
#  751|-> 			temp[1] = mtpz_aes_sbox[t2];
#  752|   			temp[2] = mtpz_aes_sbox[t3];
#  753|   			temp[3] = mtpz_aes_sbox[t0];

Error: CPPCHECK_WARNING (CWE-476): [#def230]
libmtp-1.1.22/src/mtpz.c:752: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  750|   			temp[0] = (mtpz_aes_sbox[t1] ^ mtpz_aes_rcon[rcon_i]) & 0xFF;
#  751|   			temp[1] = mtpz_aes_sbox[t2];
#  752|-> 			temp[2] = mtpz_aes_sbox[t3];
#  753|   			temp[3] = mtpz_aes_sbox[t0];
#  754|   			rcon_i++;

Error: CPPCHECK_WARNING (CWE-476): [#def231]
libmtp-1.1.22/src/mtpz.c:753: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  751|   			temp[1] = mtpz_aes_sbox[t2];
#  752|   			temp[2] = mtpz_aes_sbox[t3];
#  753|-> 			temp[3] = mtpz_aes_sbox[t0];
#  754|   			rcon_i++;
#  755|   		}

Error: CPPCHECK_WARNING (CWE-476): [#def232]
libmtp-1.1.22/src/mtpz.c:758: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  756|   		else if ((key_len > 24) && (i % key_len == 16))
#  757|   		{
#  758|-> 			temp[0] = mtpz_aes_sbox[t0];
#  759|   			temp[1] = mtpz_aes_sbox[t1];
#  760|   			temp[2] = mtpz_aes_sbox[t2];

Error: CPPCHECK_WARNING (CWE-476): [#def233]
libmtp-1.1.22/src/mtpz.c:759: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  757|   		{
#  758|   			temp[0] = mtpz_aes_sbox[t0];
#  759|-> 			temp[1] = mtpz_aes_sbox[t1];
#  760|   			temp[2] = mtpz_aes_sbox[t2];
#  761|   			temp[3] = mtpz_aes_sbox[t3];

Error: CPPCHECK_WARNING (CWE-476): [#def234]
libmtp-1.1.22/src/mtpz.c:760: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  758|   			temp[0] = mtpz_aes_sbox[t0];
#  759|   			temp[1] = mtpz_aes_sbox[t1];
#  760|-> 			temp[2] = mtpz_aes_sbox[t2];
#  761|   			temp[3] = mtpz_aes_sbox[t3];
#  762|   		}

Error: CPPCHECK_WARNING (CWE-476): [#def235]
libmtp-1.1.22/src/mtpz.c:761: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  759|   			temp[1] = mtpz_aes_sbox[t1];
#  760|   			temp[2] = mtpz_aes_sbox[t2];
#  761|-> 			temp[3] = mtpz_aes_sbox[t3];
#  762|   		}
#  763|   

Error: CPPCHECK_WARNING (CWE-476): [#def236]
libmtp-1.1.22/src/mtpz.c:766: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: key
#  764|   		for (j = 0; j < 4; j++)
#  765|   		{
#  766|-> 			key[i + j] = (unsigned char)((key[i + j - key_len] ^ temp[j]) & 0xFF);
#  767|   		}
#  768|   	}

Error: CPPCHECK_WARNING (CWE-476): [#def237]
libmtp-1.1.22/src/mtpz.c:766: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: temp
#  764|   		for (j = 0; j < 4; j++)
#  765|   		{
#  766|-> 			key[i + j] = (unsigned char)((key[i + j - key_len] ^ temp[j]) & 0xFF);
#  767|   		}
#  768|   	}

Error: CPPCHECK_WARNING (CWE-476): [#def238]
libmtp-1.1.22/src/mtpz.c:952: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: loop1
#  950|   
#  951|   	unsigned char *loop1 = (unsigned char *)malloc(17);
#  952|-> 	memset(loop1, 0, 17);
#  953|   	unsigned char *loop2 = (unsigned char *)malloc(17);
#  954|   	memset(loop2, 0, 17);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def239]
libmtp-1.1.22/src/mtpz.c:952:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'loop1' where non-null expected
libmtp-1.1.22/src/mtpz.c:951:49: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:952:9: danger: argument 1 ('loop1') from [(1)](sarif:/runs/0/results/26/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
#  950|   
#  951|   	unsigned char *loop1 = (unsigned char *)malloc(17);
#  952|-> 	memset(loop1, 0, 17);
#  953|   	unsigned char *loop2 = (unsigned char *)malloc(17);
#  954|   	memset(loop2, 0, 17);

Error: CPPCHECK_WARNING (CWE-476): [#def240]
libmtp-1.1.22/src/mtpz.c:954: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: loop2
#  952|   	memset(loop1, 0, 17);
#  953|   	unsigned char *loop2 = (unsigned char *)malloc(17);
#  954|-> 	memset(loop2, 0, 17);
#  955|   	int i = 0;
#  956|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def241]
libmtp-1.1.22/src/mtpz.c:954:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'loop2' where non-null expected
libmtp-1.1.22/src/mtpz.c:953:49: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:954:9: danger: argument 1 ('loop2') from [(1)](sarif:/runs/0/results/27/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
#  952|   	memset(loop1, 0, 17);
#  953|   	unsigned char *loop2 = (unsigned char *)malloc(17);
#  954|-> 	memset(loop2, 0, 17);
#  955|   	int i = 0;
#  956|   

Error: CPPCHECK_WARNING (CWE-476): [#def242]
libmtp-1.1.22/src/mtpz.c:959: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: enc_hash
#  957|   	{
#  958|   		unsigned char *enc_hash = (unsigned char *)malloc(17);
#  959|-> 		memset(enc_hash, 0, 17);
#  960|   		mtpz_encryption_cipher_advanced(hash, hash_length, enc_hash, 16, 1);
#  961|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def243]
libmtp-1.1.22/src/mtpz.c:959:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'enc_hash' where non-null expected
libmtp-1.1.22/src/mtpz.c:958:60: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:959:17: danger: argument 1 ('enc_hash') from [(1)](sarif:/runs/0/results/28/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
#  957|   	{
#  958|   		unsigned char *enc_hash = (unsigned char *)malloc(17);
#  959|-> 		memset(enc_hash, 0, 17);
#  960|   		mtpz_encryption_cipher_advanced(hash, hash_length, enc_hash, 16, 1);
#  961|   

Error: CPPCHECK_WARNING (CWE-476): [#def244]
libmtp-1.1.22/src/mtpz.c:963: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: enc_hash
#  961|   
#  962|   		for (i = 0; i < 16; i++)
#  963|-> 			loop1[i] = (unsigned char)((2 * enc_hash[i]) | (enc_hash[i + 1] >> 7));
#  964|   
#  965|   		if (enc_hash[0] >= (unsigned char)128)

Error: CPPCHECK_WARNING (CWE-476): [#def245]
libmtp-1.1.22/src/mtpz.c:963: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: loop1
#  961|   
#  962|   		for (i = 0; i < 16; i++)
#  963|-> 			loop1[i] = (unsigned char)((2 * enc_hash[i]) | (enc_hash[i + 1] >> 7));
#  964|   
#  965|   		if (enc_hash[0] >= (unsigned char)128)

Error: CPPCHECK_WARNING (CWE-476): [#def246]
libmtp-1.1.22/src/mtpz.c:965: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: enc_hash
#  963|   			loop1[i] = (unsigned char)((2 * enc_hash[i]) | (enc_hash[i + 1] >> 7));
#  964|   
#  965|-> 		if (enc_hash[0] >= (unsigned char)128)
#  966|   			loop1[15] ^= (unsigned char)0x87;
#  967|   

Error: CPPCHECK_WARNING (CWE-476): [#def247]
libmtp-1.1.22/src/mtpz.c:969: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: loop1
#  967|   
#  968|   		for (i = 0; i < 16; i++)
#  969|-> 			loop2[i] = (unsigned char)((2 * loop1[i]) | (loop1[i + 1] >> 7));
#  970|   
#  971|   		if (loop1[0] >= (unsigned char)128)

Error: CPPCHECK_WARNING (CWE-476): [#def248]
libmtp-1.1.22/src/mtpz.c:969: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: loop2
#  967|   
#  968|   		for (i = 0; i < 16; i++)
#  969|-> 			loop2[i] = (unsigned char)((2 * loop1[i]) | (loop1[i + 1] >> 7));
#  970|   
#  971|   		if (loop1[0] >= (unsigned char)128)

Error: CPPCHECK_WARNING (CWE-476): [#def249]
libmtp-1.1.22/src/mtpz.c:971: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: loop1
#  969|   			loop2[i] = (unsigned char)((2 * loop1[i]) | (loop1[i + 1] >> 7));
#  970|   
#  971|-> 		if (loop1[0] >= (unsigned char)128)
#  972|   			loop2[15] ^= (unsigned char)0x87;
#  973|   

Error: CPPCHECK_WARNING (CWE-476): [#def250]
libmtp-1.1.22/src/mtpz.c:984: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: actual_seed
#  982|   
#  983|   		unsigned char *actual_seed = (unsigned char *)malloc(16);
#  984|-> 		memset(actual_seed, 0, 16);
#  985|   
#  986|   		unsigned int i = 0;

Error: CPPCHECK_WARNING (CWE-476): [#def251]
libmtp-1.1.22/src/mtpz.c:1567: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: message
# 1565|   
# 1566|   	char *message = (char *)malloc(128);
# 1567|-> 	memcpy(message, reader, 128);
# 1568|   	reader += 128;
# 1569|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def252]
libmtp-1.1.22/src/mtpz.c:1567:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'message' where non-null expected
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1566:33: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:1567:9: danger: argument 1 ('message') from [(9)](sarif:/runs/0/results/29/codeFlows/0/threadFlows/0/locations/8) could be NULL where non-null expected
# 1565|   
# 1566|   	char *message = (char *)malloc(128);
# 1567|-> 	memcpy(message, reader, 128);
# 1568|   	reader += 128;
# 1569|   

Error: CPPCHECK_WARNING (CWE-476): [#def253]
libmtp-1.1.22/src/mtpz.c:1572: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: msg_dec
# 1570|   	// Decrypt the hash-key-message..
# 1571|   	char *msg_dec = (char *)malloc(128);
# 1572|-> 	memset(msg_dec, 0, 128);
# 1573|   
# 1574|   	mtpz_rsa_t *rsa = mtpz_rsa_init(MTPZ_MODULUS, MTPZ_PRIVATE_KEY, MTPZ_PUBLIC_EXPONENT);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def254]
libmtp-1.1.22/src/mtpz.c:1572:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'msg_dec' where non-null expected
libmtp-1.1.22/src/mtpz.c:1540:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1546:15: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1549:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1554:13: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1554:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1561:14: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1561:12: branch_false: following 'false' branch...
libmtp-1.1.22/src/mtpz.c:1566:33: branch_false: ...to here
libmtp-1.1.22/src/mtpz.c:1571:33: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:1572:9: danger: argument 1 ('msg_dec') from [(9)](sarif:/runs/0/results/30/codeFlows/0/threadFlows/0/locations/8) could be NULL where non-null expected
# 1570|   	// Decrypt the hash-key-message..
# 1571|   	char *msg_dec = (char *)malloc(128);
# 1572|-> 	memset(msg_dec, 0, 128);
# 1573|   
# 1574|   	mtpz_rsa_t *rsa = mtpz_rsa_init(MTPZ_MODULUS, MTPZ_PRIVATE_KEY, MTPZ_PUBLIC_EXPONENT);

Error: CPPCHECK_WARNING (CWE-476): [#def255]
libmtp-1.1.22/src/mtpz.c:1608: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: hash_key
# 1606|   		msg_dec[i + 21] ^= v11[i];
# 1607|   
# 1608|-> 	memcpy(hash_key, msg_dec + 112, 16);
# 1609|   
# 1610|   	// Encrypted message is 0x340 bytes.

Error: CPPCHECK_WARNING (CWE-476): [#def256]
libmtp-1.1.22/src/mtpz.c:1622: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: act_msg
# 1620|   	unsigned char *act_msg = (unsigned char *)malloc(832);
# 1621|   	unsigned char *act_reader = act_msg;
# 1622|-> 	memcpy(act_msg, reader, 832);
# 1623|   	reader = NULL;
# 1624|   

Error: CPPCHECK_WARNING (CWE-682): [#def257]
libmtp-1.1.22/src/mtpz.c:1627: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
# 1625|   	mtpz_encryption_cipher_advanced((unsigned char *)hash_key, 16, act_msg, 832, 0);
# 1626|   
# 1627|-> 	act_reader++;
# 1628|   	unsigned int certs_length = MTPZ_SWAP(*(unsigned int *)(act_reader));
# 1629|   	act_reader += 4;

Error: CPPCHECK_WARNING (CWE-476): [#def258]
libmtp-1.1.22/src/mtpz.c:1635: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: rand_data
# 1633|   	act_reader += 2;
# 1634|   	unsigned char *rand_data = (unsigned char *)malloc(rand_length);
# 1635|-> 	memcpy(rand_data, act_reader, rand_length);
# 1636|   	if (memcmp(rand_data, random, 16) != 0)
# 1637|   	{

Error: CPPCHECK_WARNING (CWE-476): [#def259]
libmtp-1.1.22/src/mtpz.c:1636: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: rand_data
# 1634|   	unsigned char *rand_data = (unsigned char *)malloc(rand_length);
# 1635|   	memcpy(rand_data, act_reader, rand_length);
# 1636|-> 	if (memcmp(rand_data, random, 16) != 0)
# 1637|   	{
# 1638|   		free(rand_data);

Error: CPPCHECK_WARNING (CWE-476): [#def260]
libmtp-1.1.22/src/mtpz.c:1662: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: machash_data
# 1660|   	act_reader += 2;
# 1661|   	unsigned char *machash_data = (unsigned char *)malloc(machash_length);
# 1662|-> 	memcpy(machash_data, act_reader, machash_length);
# 1663|   	act_reader += machash_length;
# 1664|   

Error: CPPCHECK_WARNING (CWE-476): [#def261]
libmtp-1.1.22/src/mtpz.c:1701: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: acm
# 1699|   	unsigned char *acm = (unsigned char *)malloc(785);
# 1700|   	unsigned char *target = acm;
# 1701|-> 	memset(acm, 0, 785);
# 1702|   
# 1703|   	unsigned char *random = (unsigned char *)malloc(16);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def262]
libmtp-1.1.22/src/mtpz.c:1701:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'acm' where non-null expected
libmtp-1.1.22/src/mtpz.c:1699:47: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:1701:9: danger: argument 1 ('acm') from [(1)](sarif:/runs/0/results/31/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
# 1699|   	unsigned char *acm = (unsigned char *)malloc(785);
# 1700|   	unsigned char *target = acm;
# 1701|-> 	memset(acm, 0, 785);
# 1702|   
# 1703|   	unsigned char *random = (unsigned char *)malloc(16);

Error: CPPCHECK_WARNING (CWE-682): [#def263]
libmtp-1.1.22/src/mtpz.c:1709: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
# 1707|   
# 1708|   	// Write the marker bytes, length of certificates, and certificates themselves.
# 1709|-> 	*(target++) = '\x02';
# 1710|   	*(target++) = '\x01';
# 1711|   	*(target++) = '\x01';

Error: CPPCHECK_WARNING (CWE-476): [#def264]
libmtp-1.1.22/src/mtpz.c:1709: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: target++
# 1707|   
# 1708|   	// Write the marker bytes, length of certificates, and certificates themselves.
# 1709|-> 	*(target++) = '\x02';
# 1710|   	*(target++) = '\x01';
# 1711|   	*(target++) = '\x01';

Error: GCC_ANALYZER_WARNING (CWE-476): [#def265]
libmtp-1.1.22/src/mtpz.c:1724:17: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'random'
libmtp-1.1.22/src/mtpz.c:1703:50: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:1723:21: branch_true: following 'true' branch (when 'i != 16')...
libmtp-1.1.22/src/mtpz.c:1724:49: branch_true: ...to here
libmtp-1.1.22/src/mtpz.c:1724:17: danger: 'random + (sizetype)i' could be NULL: unchecked value from [(1)](sarif:/runs/0/results/32/codeFlows/0/threadFlows/0/locations/0)
# 1722|   
# 1723|   	for (i = 0; i < 16; i++)
# 1724|-> 		*(random + i) = (unsigned char)(rand() % 256);
# 1725|   
# 1726|   	*out_random = random;

Error: CPPCHECK_WARNING (CWE-476): [#def266]
libmtp-1.1.22/src/mtpz.c:1727: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: random
# 1725|   
# 1726|   	*out_random = random;
# 1727|-> 	memcpy(target, random, 16);
# 1728|   	target += 16;
# 1729|   

Error: CPPCHECK_WARNING (CWE-476): [#def267]
libmtp-1.1.22/src/mtpz.c:1731: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: v16
# 1729|   
# 1730|   	char *state = mtpz_hash_init_state();
# 1731|-> 	char *v16 = (char *)malloc(28); memset(v16, 0, 28);
# 1732|   	char *hash = (char *)malloc(20); memset(hash, 0, 20);
# 1733|   	char *odata = (char *)malloc(128); memset(odata, 0, 128);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def268]
libmtp-1.1.22/src/mtpz.c:1731:41: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'v16' where non-null expected
libmtp-1.1.22/src/mtpz.c:1695:1: enter_function: entry to 'ptp_mtpz_makeapplicationcertificatemessage'
libmtp-1.1.22/src/mtpz.c:1723:21: branch_true: following 'true' branch (when 'i != 16')...
libmtp-1.1.22/src/mtpz.c:1724:49: branch_true: ...to here
libmtp-1.1.22/src/mtpz.c:1723:21: branch_true: following 'true' branch (when 'i != 16')...
libmtp-1.1.22/src/mtpz.c:1724:49: branch_true: ...to here
libmtp-1.1.22/src/mtpz.c:1730:23: call_function: calling 'mtpz_hash_init_state' from 'ptp_mtpz_makeapplicationcertificatemessage'
libmtp-1.1.22/src/mtpz.c:1730:23: return_function: returning to 'ptp_mtpz_makeapplicationcertificatemessage' from 'mtpz_hash_init_state'
libmtp-1.1.22/src/mtpz.c:1731:29: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:1731:41: danger: argument 1 ('v16') from [(11)](sarif:/runs/0/results/33/codeFlows/0/threadFlows/0/locations/10) could be NULL where non-null expected
# 1729|   
# 1730|   	char *state = mtpz_hash_init_state();
# 1731|-> 	char *v16 = (char *)malloc(28); memset(v16, 0, 28);
# 1732|   	char *hash = (char *)malloc(20); memset(hash, 0, 20);
# 1733|   	char *odata = (char *)malloc(128); memset(odata, 0, 128);

Error: CPPCHECK_WARNING (CWE-476): [#def269]
libmtp-1.1.22/src/mtpz.c:1732: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: hash
# 1730|   	char *state = mtpz_hash_init_state();
# 1731|   	char *v16 = (char *)malloc(28); memset(v16, 0, 28);
# 1732|-> 	char *hash = (char *)malloc(20); memset(hash, 0, 20);
# 1733|   	char *odata = (char *)malloc(128); memset(odata, 0, 128);
# 1734|   

Error: CPPCHECK_WARNING (CWE-476): [#def270]
libmtp-1.1.22/src/mtpz.c:1733: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: odata
# 1731|   	char *v16 = (char *)malloc(28); memset(v16, 0, 28);
# 1732|   	char *hash = (char *)malloc(20); memset(hash, 0, 20);
# 1733|-> 	char *odata = (char *)malloc(128); memset(odata, 0, 128);
# 1734|   
# 1735|   	mtpz_hash_reset_state(state);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def271]
libmtp-1.1.22/src/mtpz.c:1733:44: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'odata' where non-null expected
libmtp-1.1.22/src/mtpz.c:1695:1: enter_function: entry to 'ptp_mtpz_makeapplicationcertificatemessage'
libmtp-1.1.22/src/mtpz.c:1723:21: branch_true: following 'true' branch (when 'i != 16')...
libmtp-1.1.22/src/mtpz.c:1724:49: branch_true: ...to here
libmtp-1.1.22/src/mtpz.c:1723:21: branch_true: following 'true' branch (when 'i != 16')...
libmtp-1.1.22/src/mtpz.c:1724:49: branch_true: ...to here
libmtp-1.1.22/src/mtpz.c:1730:23: call_function: calling 'mtpz_hash_init_state' from 'ptp_mtpz_makeapplicationcertificatemessage'
libmtp-1.1.22/src/mtpz.c:1730:23: return_function: returning to 'ptp_mtpz_makeapplicationcertificatemessage' from 'mtpz_hash_init_state'
libmtp-1.1.22/src/mtpz.c:1733:31: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:1733:44: danger: argument 1 ('odata') from [(11)](sarif:/runs/0/results/34/codeFlows/0/threadFlows/0/locations/10) could be NULL where non-null expected
# 1731|   	char *v16 = (char *)malloc(28); memset(v16, 0, 28);
# 1732|   	char *hash = (char *)malloc(20); memset(hash, 0, 20);
# 1733|-> 	char *odata = (char *)malloc(128); memset(odata, 0, 128);
# 1734|   
# 1735|   	mtpz_hash_reset_state(state);

Error: CPPCHECK_WARNING (CWE-682): [#def272]
libmtp-1.1.22/src/mtpz.c:1736: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
# 1734|   
# 1735|   	mtpz_hash_reset_state(state);
# 1736|-> 	mtpz_hash_transform_hash(state, (char *)acm + 2, (target - acm - 2));
# 1737|   	mtpz_hash_finalize_hash(state, v16 + 8);
# 1738|   

Error: CPPCHECK_WARNING (CWE-682): [#def273]
libmtp-1.1.22/src/mtpz.c:1737: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
# 1735|   	mtpz_hash_reset_state(state);
# 1736|   	mtpz_hash_transform_hash(state, (char *)acm + 2, (target - acm - 2));
# 1737|-> 	mtpz_hash_finalize_hash(state, v16 + 8);
# 1738|   
# 1739|   	mtpz_hash_reset_state(state);

Error: CPPCHECK_WARNING (CWE-476): [#def274]
libmtp-1.1.22/src/mtpz.c:1746: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: hash
# 1744|   
# 1745|   	for (i = 0; i < 20; i++)
# 1746|-> 		odata[107 + i] = hash[i];
# 1747|   
# 1748|   	odata[106] = '\x01';

Error: CPPCHECK_WARNING (CWE-476): [#def275]
libmtp-1.1.22/src/mtpz.c:1746: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: odata
# 1744|   
# 1745|   	for (i = 0; i < 20; i++)
# 1746|-> 		odata[107 + i] = hash[i];
# 1747|   
# 1748|   	odata[106] = '\x01';

Error: CPPCHECK_WARNING (CWE-476): [#def276]
libmtp-1.1.22/src/mtpz.c:1748: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: odata
# 1746|   		odata[107 + i] = hash[i];
# 1747|   
# 1748|-> 	odata[106] = '\x01';
# 1749|   
# 1750|   	if (v17 != NULL)

Error: CPPCHECK_WARNING (CWE-476): [#def277]
libmtp-1.1.22/src/mtpz.c:1776: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: signature
# 1774|   
# 1775|   	char *signature = (char *)malloc(128);
# 1776|-> 	memset(signature, 0, 128);
# 1777|   	mtpz_rsa_sign(128, (unsigned char *)odata, 128, (unsigned char *)signature, rsa);
# 1778|   

Error: CPPCHECK_WARNING (CWE-476): [#def278]
libmtp-1.1.22/src/mtpz.c:1785: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: signature
# 1783|   	// Write the signature + bytes.
# 1784|   	*(target++) = '\x01'; *(target++) = '\x00'; *(target++) = '\x80';
# 1785|-> 	memcpy(target, signature, 128);
# 1786|   
# 1787|   	// Kill target.

Error: CPPCHECK_WARNING (CWE-476): [#def279]
libmtp-1.1.22/src/mtpz.c:1798: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: message
# 1796|   	*out_len = 20;
# 1797|   	unsigned char *message = (unsigned char *)malloc(20);
# 1798|-> 	message[0] = (unsigned char)0x02;
# 1799|   	message[1] = (unsigned char)0x03;
# 1800|   	message[2] = (unsigned char)0x00;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def280]
libmtp-1.1.22/src/mtpz.c:1798:9: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'message'
libmtp-1.1.22/src/mtpz.c:1797:51: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:1798:9: danger: 'message' could be NULL: unchecked value from [(1)](sarif:/runs/0/results/35/codeFlows/0/threadFlows/0/locations/0)
# 1796|   	*out_len = 20;
# 1797|   	unsigned char *message = (unsigned char *)malloc(20);
# 1798|-> 	message[0] = (unsigned char)0x02;
# 1799|   	message[1] = (unsigned char)0x03;
# 1800|   	message[2] = (unsigned char)0x00;

Error: CPPCHECK_WARNING (CWE-476): [#def281]
libmtp-1.1.22/src/mtpz.c:1799: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: message
# 1797|   	unsigned char *message = (unsigned char *)malloc(20);
# 1798|   	message[0] = (unsigned char)0x02;
# 1799|-> 	message[1] = (unsigned char)0x03;
# 1800|   	message[2] = (unsigned char)0x00;
# 1801|   	message[3] = (unsigned char)0x10;

Error: CPPCHECK_WARNING (CWE-476): [#def282]
libmtp-1.1.22/src/mtpz.c:1800: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: message
# 1798|   	message[0] = (unsigned char)0x02;
# 1799|   	message[1] = (unsigned char)0x03;
# 1800|-> 	message[2] = (unsigned char)0x00;
# 1801|   	message[3] = (unsigned char)0x10;
# 1802|   

Error: CPPCHECK_WARNING (CWE-476): [#def283]
libmtp-1.1.22/src/mtpz.c:1801: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: message
# 1799|   	message[1] = (unsigned char)0x03;
# 1800|   	message[2] = (unsigned char)0x00;
# 1801|-> 	message[3] = (unsigned char)0x10;
# 1802|   
# 1803|   	unsigned char *seed = (unsigned char *)malloc(16);

Error: CPPCHECK_WARNING (CWE-476): [#def284]
libmtp-1.1.22/src/mtpz.c:1804: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: seed
# 1802|   
# 1803|   	unsigned char *seed = (unsigned char *)malloc(16);
# 1804|-> 	memset(seed, 0, 16);
# 1805|   	seed[15] = (unsigned char)(0x01);
# 1806|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def285]
libmtp-1.1.22/src/mtpz.c:1804:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'seed' where non-null expected
libmtp-1.1.22/src/mtpz.c:1803:48: acquire_memory: this call could return NULL
libmtp-1.1.22/src/mtpz.c:1804:9: danger: argument 1 ('seed') from [(1)](sarif:/runs/0/results/36/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
# 1802|   
# 1803|   	unsigned char *seed = (unsigned char *)malloc(16);
# 1804|-> 	memset(seed, 0, 16);
# 1805|   	seed[15] = (unsigned char)(0x01);
# 1806|   

Error: CPPCHECK_WARNING (CWE-476): [#def286]
libmtp-1.1.22/src/mtpz.c:1805: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: seed
# 1803|   	unsigned char *seed = (unsigned char *)malloc(16);
# 1804|   	memset(seed, 0, 16);
# 1805|-> 	seed[15] = (unsigned char)(0x01);
# 1806|   
# 1807|   	mtpz_encryption_encrypt_mac(hash, 16u, seed, 16u, message + 4);

Error: CPPCHECK_WARNING (CWE-682): [#def287]
libmtp-1.1.22/src/mtpz.c:1807: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
# 1805|   	seed[15] = (unsigned char)(0x01);
# 1806|   
# 1807|-> 	mtpz_encryption_encrypt_mac(hash, 16u, seed, 16u, message + 4);
# 1808|   
# 1809|   	free(seed);

Error: CPPCHECK_WARNING (CWE-476): [#def288]
libmtp-1.1.22/src/playlist-spl.c:222: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  220|     // create the file object for storing
#  221|     LIBMTP_file_t* f = malloc(sizeof(LIBMTP_file_t));
#  222|->   f->item_id = 0;
#  223|     f->parent_id = pl->parent_id;
#  224|     f->storage_id = pl->storage_id;

Error: CPPCHECK_WARNING (CWE-476): [#def289]
libmtp-1.1.22/src/playlist-spl.c:223: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  221|     LIBMTP_file_t* f = malloc(sizeof(LIBMTP_file_t));
#  222|     f->item_id = 0;
#  223|->   f->parent_id = pl->parent_id;
#  224|     f->storage_id = pl->storage_id;
#  225|     f->filename = malloc(sizeof(char)*(strlen(pl->name)+5));

Error: CPPCHECK_WARNING (CWE-476): [#def290]
libmtp-1.1.22/src/playlist-spl.c:224: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  222|     f->item_id = 0;
#  223|     f->parent_id = pl->parent_id;
#  224|->   f->storage_id = pl->storage_id;
#  225|     f->filename = malloc(sizeof(char)*(strlen(pl->name)+5));
#  226|     strcpy(f->filename, pl->name);

Error: CPPCHECK_WARNING (CWE-476): [#def291]
libmtp-1.1.22/src/playlist-spl.c:225: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  223|     f->parent_id = pl->parent_id;
#  224|     f->storage_id = pl->storage_id;
#  225|->   f->filename = malloc(sizeof(char)*(strlen(pl->name)+5));
#  226|     strcpy(f->filename, pl->name);
#  227|     strcat(f->filename, ".spl"); // append suffix

Error: CPPCHECK_WARNING (CWE-476): [#def292]
libmtp-1.1.22/src/playlist-spl.c:226: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  224|     f->storage_id = pl->storage_id;
#  225|     f->filename = malloc(sizeof(char)*(strlen(pl->name)+5));
#  226|->   strcpy(f->filename, pl->name);
#  227|     strcat(f->filename, ".spl"); // append suffix
#  228|     f->filesize = lseek(fd, 0, SEEK_CUR); // file desc is currently at end of file

Error: CPPCHECK_WARNING (CWE-476): [#def293]
libmtp-1.1.22/src/playlist-spl.c:227: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  225|     f->filename = malloc(sizeof(char)*(strlen(pl->name)+5));
#  226|     strcpy(f->filename, pl->name);
#  227|->   strcat(f->filename, ".spl"); // append suffix
#  228|     f->filesize = lseek(fd, 0, SEEK_CUR); // file desc is currently at end of file
#  229|     f->filetype = LIBMTP_FILETYPE_UNKNOWN;

Error: CPPCHECK_WARNING (CWE-476): [#def294]
libmtp-1.1.22/src/playlist-spl.c:228: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  226|     strcpy(f->filename, pl->name);
#  227|     strcat(f->filename, ".spl"); // append suffix
#  228|->   f->filesize = lseek(fd, 0, SEEK_CUR); // file desc is currently at end of file
#  229|     f->filetype = LIBMTP_FILETYPE_UNKNOWN;
#  230|     f->next = NULL;

Error: CPPCHECK_WARNING (CWE-476): [#def295]
libmtp-1.1.22/src/playlist-spl.c:229: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  227|     strcat(f->filename, ".spl"); // append suffix
#  228|     f->filesize = lseek(fd, 0, SEEK_CUR); // file desc is currently at end of file
#  229|->   f->filetype = LIBMTP_FILETYPE_UNKNOWN;
#  230|     f->next = NULL;
#  231|   

Error: CPPCHECK_WARNING (CWE-476): [#def296]
libmtp-1.1.22/src/playlist-spl.c:230: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: f
#  228|     f->filesize = lseek(fd, 0, SEEK_CUR); // file desc is currently at end of file
#  229|     f->filetype = LIBMTP_FILETYPE_UNKNOWN;
#  230|->   f->next = NULL;
#  231|   
#  232|     LIBMTP_PLST_DEBUG("%s is %dB\n", f->filename, (int)f->filesize);

Error: CPPCHECK_WARNING (CWE-476): [#def297]
libmtp-1.1.22/src/playlist-spl.c:307: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: s
#  305|       LIBMTP_PLST_DEBUG("playlist_id will remain unchanged\n");
#  306|       char* s = malloc(sizeof(char)*(strlen(newlist->name)+5));
#  307|->     strcpy(s, newlist->name);
#  308|       strcat(s,".spl"); // FIXME check for success
#  309|       int ret = LIBMTP_Set_Playlist_Name(device, newlist, s);

Error: CPPCHECK_WARNING (CWE-476): [#def298]
libmtp-1.1.22/src/playlist-spl.c:308: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: s
#  306|       char* s = malloc(sizeof(char)*(strlen(newlist->name)+5));
#  307|       strcpy(s, newlist->name);
#  308|->     strcat(s,".spl"); // FIXME check for success
#  309|       int ret = LIBMTP_Set_Playlist_Name(device, newlist, s);
#  310|       free(s);

Error: CPPCHECK_WARNING (CWE-476): [#def299]
libmtp-1.1.22/src/playlist-spl.c:406: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: tail
#  404|           // fill in the data for the node
#  405|           //  ... cast as a string of 2 byte characters
#  406|->         tail->text = utf16_to_utf8(device, (uint16_t*) w);
#  407|           iw = w; // start again
#  408|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def300]
libmtp-1.1.22/src/playlist-spl.c:645:1: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/playlist-spl.c:588:13: enter_function: entry to 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:600:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:600:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:606:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:606:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:607:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:607:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:612:11: branch_true: following 'true' branch (when 'i < trackno')...
libmtp-1.1.22/src/playlist-spl.c:613:41: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:613:5: call_function: calling 'discover_filepath_from_id' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:613:5: return_function: returning to 'spl_text_t_from_tracks' from 'discover_filepath_from_id'
libmtp-1.1.22/src/playlist-spl.c:615:7: branch_true: following 'true' branch...
libmtp-1.1.22/src/playlist-spl.c:616:7: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:616:7: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:616:7: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:612:11: branch_false: following 'false' branch (when 'i >= trackno')...
libmtp-1.1.22/src/playlist-spl.c:625:3: branch_false: ...to here
libmtp-1.1.22/src/playlist-spl.c:625:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:625:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:626:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:626:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:627:5: branch_false: following 'false' branch (when 'ver_major != 2')...
libmtp-1.1.22/src/playlist-spl.c:640:4: branch_false: ...to here
libmtp-1.1.22/src/playlist-spl.c:645:1: danger: '<unknown>' leaks here; was allocated at [(69)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/68)
#  643|     LIBMTP_PLST_DEBUG(".spl playlist:\n");
#  644|     print_spl_text_t(*p);
#  645|-> }
#  646|   
#  647|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def301]
libmtp-1.1.22/src/playlist-spl.c:645:1: warning[-Wanalyzer-malloc-leak]: leak of 'c'
libmtp-1.1.22/src/playlist-spl.c:588:13: enter_function: entry to 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:600:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:600:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:606:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:606:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:607:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:607:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:612:11: branch_true: following 'true' branch (when 'i < trackno')...
libmtp-1.1.22/src/playlist-spl.c:613:41: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:613:5: call_function: calling 'discover_filepath_from_id' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:613:5: return_function: returning to 'spl_text_t_from_tracks' from 'discover_filepath_from_id'
libmtp-1.1.22/src/playlist-spl.c:615:7: branch_true: following 'true' branch...
libmtp-1.1.22/src/playlist-spl.c:616:7: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:616:7: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:616:7: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:612:11: branch_false: following 'false' branch (when 'i >= trackno')...
libmtp-1.1.22/src/playlist-spl.c:625:3: branch_false: ...to here
libmtp-1.1.22/src/playlist-spl.c:625:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:625:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:626:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:626:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:627:5: branch_false: following 'false' branch (when 'ver_major != 2')...
libmtp-1.1.22/src/playlist-spl.c:640:4: branch_false: ...to here
libmtp-1.1.22/src/playlist-spl.c:645:1: danger: 'c' leaks here; was allocated at [(64)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/63)
#  643|     LIBMTP_PLST_DEBUG(".spl playlist:\n");
#  644|     print_spl_text_t(*p);
#  645|-> }
#  646|   
#  647|   

Error: CPPCHECK_WARNING (CWE-682): [#def302]
libmtp-1.1.22/src/playlist-spl.c:731: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  729|     uint32_t id = 0;
#  730|     char* sc = strdup(s);
#  731|->   char* sci = sc +1; // iterator
#  732|     // skip leading slash in path
#  733|   

Error: CPPCHECK_WARNING (CWE-476): [#def303]
libmtp-1.1.22/src/playlist-spl.c:737: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: sc
#  735|     size_t len = strlen(s);
#  736|     for(i=0;i<len;i++) {
#  737|->     if(sc[i] == '\\') {
#  738|         sc[i] = '\0';
#  739|       }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def304]
libmtp-1.1.22/src/playlist-spl.c:737:8: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'sc'
libmtp-1.1.22/src/playlist-spl.c:725:5: branch_false: following 'false' branch...
libmtp-1.1.22/src/playlist-spl.c:730:14: branch_false: ...to here
libmtp-1.1.22/src/playlist-spl.c:730:14: acquire_memory: this call could return NULL
libmtp-1.1.22/src/playlist-spl.c:736:11: branch_true: following 'true' branch...
libmtp-1.1.22/src/playlist-spl.c:737:10: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:737:8: danger: 'sc + (long unsigned int)i' could be NULL: unchecked value from [(3)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/2)
#  735|     size_t len = strlen(s);
#  736|     for(i=0;i<len;i++) {
#  737|->     if(sc[i] == '\\') {
#  738|         sc[i] = '\0';
#  739|       }

Error: CPPCHECK_WARNING (CWE-682): [#def305]
libmtp-1.1.22/src/playlist-spl.c:743: error[nullPointerArithmeticOutOfMemory]: If memory allocation fails: pointer addition with NULL pointer.
#  741|   
#  742|     // now for each part of the string, find the id
#  743|->   while(sci != sc + len +1) {
#  744|       // if its the last part of the string, its the filename
#  745|       if(sci + strlen(sci) == sc + len) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def306]
libmtp-1.1.22/src/playlist-spl.c:845:5: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
libmtp-1.1.22/src/playlist-spl.c:588:13: enter_function: entry to 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:600:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:600:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:606:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:606:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:607:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:607:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:612:11: branch_true: following 'true' branch (when 'i < trackno')...
libmtp-1.1.22/src/playlist-spl.c:613:41: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:613:5: call_function: calling 'discover_filepath_from_id' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:613:5: return_function: returning to 'spl_text_t_from_tracks' from 'discover_filepath_from_id'
libmtp-1.1.22/src/playlist-spl.c:615:7: branch_true: following 'true' branch...
libmtp-1.1.22/src/playlist-spl.c:616:7: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:616:7: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:616:7: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:612:11: branch_false: following 'false' branch (when 'i >= trackno')...
libmtp-1.1.22/src/playlist-spl.c:625:3: branch_false: ...to here
libmtp-1.1.22/src/playlist-spl.c:625:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:625:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:626:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:626:3: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:627:5: branch_true: following 'true' branch (when 'ver_major == 2')...
libmtp-1.1.22/src/playlist-spl.c:628:5: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:628:5: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:628:5: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:629:5: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:629:5: return_function: returning to 'spl_text_t_from_tracks' from 'append_text_t'
libmtp-1.1.22/src/playlist-spl.c:630:7: branch_true: following 'true' branch (when 'dnse' is non-NULL)...
libmtp-1.1.22/src/playlist-spl.c:631:7: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:631:7: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
#  843|     }
#  844|     else {
#  845|->     (*t)->next = malloc(sizeof(text_t));
#  846|       (*t) = (*t)->next;
#  847|     }

Error: CPPCHECK_WARNING (CWE-476): [#def307]
libmtp-1.1.22/src/playlist-spl.c:848: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: *t
#  846|       (*t) = (*t)->next;
#  847|     }
#  848|->   (*t)->text = strdup(s);
#  849|   }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def308]
libmtp-1.1.22/src/playlist-spl.c:848:3: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL '*t'
libmtp-1.1.22/src/playlist-spl.c:841:5: branch_true: following 'true' branch...
libmtp-1.1.22/src/playlist-spl.c:842:10: branch_true: ...to here
libmtp-1.1.22/src/playlist-spl.c:842:10: acquire_memory: this call could return NULL
libmtp-1.1.22/src/playlist-spl.c:848:3: danger: '*t' could be NULL: unchecked value from [(3)](sarif:/runs/0/results/7/codeFlows/0/threadFlows/0/locations/2)
#  846|       (*t) = (*t)->next;
#  847|     }
#  848|->   (*t)->text = strdup(s);
#  849|   }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def309]
libmtp-1.1.22/src/playlist-spl.c:848:3: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'c'
libmtp-1.1.22/src/playlist-spl.c:588:13: enter_function: entry to 'spl_text_t_from_tracks'
libmtp-1.1.22/src/playlist-spl.c:600:3: call_function: calling 'append_text_t' from 'spl_text_t_from_tracks'
#  846|       (*t) = (*t)->next;
#  847|     }
#  848|->   (*t)->text = strdup(s);
#  849|   }

Error: CPPCHECK_WARNING (CWE-476): [#def310]
libmtp-1.1.22/src/ptp-pack.c:661: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: oidata
#  659|   	char *capture_date="20020101T010101"; /* XXX Fake date */
#  660|   #endif
#  661|-> 	memset (oidata, 0, PTP_oi_MaxLen + params->ocs64*4);
#  662|   	htod32a(&oidata[PTP_oi_StorageID],oi->StorageID);
#  663|   	htod16a(&oidata[PTP_oi_ObjectFormat],oi->ObjectFormat);

Error: COMPILER_WARNING: [#def311]
libmtp-1.1.22/src/ptp.c:125: included_from: Included from here.
libmtp-1.1.22/src/ptp-pack.c: scope_hint: In function 'ptp_unpack_PTPTIME.part.0'
libmtp-1.1.22/src/ptp-pack.c:729:9: warning[-Wstringop-truncation]: 'strncpy' specified bound 40 equals destination size
#  729 |         strncpy (ptpdate, str, sizeof(ptpdate));
#      |         ^
#  727|   		return 0;
#  728|   	}
#  729|-> 	strncpy (ptpdate, str, sizeof(ptpdate));
#  730|   	ptpdate[sizeof(ptpdate) - 1] = '\0';
#  731|   

Error: CPPCHECK_WARNING (CWE-476): [#def312]
libmtp-1.1.22/src/ptp-pack.c:1290: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: (uint8_t*)(dpv)
# 1288|   		size=sizeof(int8_t);
# 1289|   		dpv=malloc(size);
# 1290|-> 		htod8a(dpv,value->i8);
# 1291|   		break;
# 1292|   	case PTP_DTC_UINT8:

Error: CPPCHECK_WARNING (CWE-476): [#def313]
libmtp-1.1.22/src/ptp-pack.c:1295: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: (uint8_t*)(dpv)
# 1293|   		size=sizeof(uint8_t);
# 1294|   		dpv=malloc(size);
# 1295|-> 		htod8a(dpv,value->u8);
# 1296|   		break;
# 1297|   	case PTP_DTC_INT16:

Error: COMPILER_WARNING: [#def314]
libmtp-1.1.22/src/ptp.c: scope_hint: In function 'ptp_nikon_getwifiprofilelist'
libmtp-1.1.22/src/ptp.c:4604:17: warning[-Wstringop-truncation]: 'strncpy' specified bound 16 equals destination size
# 4604 |                 strncpy(params->wifi_profiles[profn].creation_date, buffer, sizeof(params->wifi_profiles[profn].creation_date));
#      |                 ^
# 4602|   		if (!ptp_unpack_string(params, data, pos, size, &len, &buffer))
# 4603|   			goto exit;
# 4604|-> 		strncpy(params->wifi_profiles[profn].creation_date, buffer, sizeof(params->wifi_profiles[profn].creation_date));
# 4605|   		free (buffer);
# 4606|   		pos += (len*2+1);

Error: COMPILER_WARNING: [#def315]
libmtp-1.1.22/src/ptp.c:4612:17: warning[-Wstringop-truncation]: 'strncpy' specified bound 16 equals destination size
# 4612 |                 strncpy(params->wifi_profiles[profn].lastusage_date, buffer, sizeof(params->wifi_profiles[profn].lastusage_date));
#      |                 ^
# 4610|   		if (!ptp_unpack_string(params, data, pos, size, &len, &buffer))
# 4611|   			goto exit;
# 4612|-> 		strncpy(params->wifi_profiles[profn].lastusage_date, buffer, sizeof(params->wifi_profiles[profn].lastusage_date));
# 4613|   		free (buffer);
# 4614|   		pos += (len*2+1);

Error: COMPILER_WARNING: [#def316]
libmtp-1.1.22/src/ptp.c: scope_hint: In function 'ptp_nikon_writewifiprofile'
libmtp-1.1.22/src/ptp.c:4699:9: warning[-Wstringop-truncation]: 'strncpy' output may be truncated copying 16 bytes from a string of length 16
# 4699 |         strncpy((char*)&buffer[0x05], profile->profile_name, 16);
#      |         ^
# 4697|   	htod32a(&buffer[0x01], 17);
# 4698|   	/* 16 as third parameter, so there will always be a null-byte in the end */
# 4699|-> 	strncpy((char*)&buffer[0x05], profile->profile_name, 16);
# 4700|   
# 4701|   	buffer[0x16] = 0x00; /* Display order */

Error: CPPCHECK_WARNING (CWE-476): [#def317]
libmtp-1.1.22/src/ptp.c:5200: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: *msg
# 5198|   	/* for convenience, always allocate an extra byte and null it*/
# 5199|   	*msg = malloc(sizeof(ptp_chdk_script_msg) + ptp.Param4 + 1);
# 5200|-> 	(*msg)->type = ptp.Param1;
# 5201|   	(*msg)->subtype = ptp.Param2;
# 5202|   	(*msg)->script_id = ptp.Param3;

Error: COMPILER_WARNING: [#def318]
libmtp-1.1.22/src/ptp.c: scope_hint: In function 'ptp_fuji_getdeviceinfo'
libmtp-1.1.22/src/ptp.c:5319:45: warning[-Wunused-but-set-variable=]: variable 'xsize' set but not used
# 5319 |         unsigned int    nums, i, newoffset, xsize, size  = 0;
#      |                                             ^~~~~
# 5317|   	unsigned char	*xdata;
# 5318|   	unsigned char	*data = NULL;
# 5319|-> 	unsigned int	nums, i, newoffset, xsize, size  = 0;
# 5320|   
# 5321|           PTP_CNT_INIT(ptp, PTP_OC_FUJI_GetDeviceInfo);

Error: CPPCHECK_WARNING (CWE-457): [#def319]
libmtp-1.1.22/src/ptp.c:8866: error[uninitvar]: Uninitialized variables: &tmpob.flags, &tmpob.oi, &tmpob.canon_flags, &tmpob.mtpprops, &tmpob.nrofmtpprops
# 8864|   
# 8865|   	tmpob.oid = handle;
# 8866|-> 	*retob = bsearch (&tmpob, params->objects, params->nrofobjects, sizeof(tmpob), _cmp_ob);
# 8867|   	if (!*retob)
# 8868|   		return PTP_RC_GeneralError;

Error: CPPCHECK_WARNING (CWE-476): [#def320]
libmtp-1.1.22/src/unicode.c:143: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: ret
#  141|     int ret_len = ucs2_strlen((uint16_t*)unicstr)*sizeof(uint16_t)+2;
#  142|     uint16_t* ret = malloc(ret_len);
#  143|->   memcpy(ret,unicstr,(size_t)ret_len);
#  144|     return ret;
#  145|   }

Error: GCC_ANALYZER_WARNING (CWE-688): [#def321]
libmtp-1.1.22/src/unicode.c:143:3: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'ret' where non-null expected
libmtp-1.1.22/src/unicode.c:142:19: acquire_memory: this call could return NULL
libmtp-1.1.22/src/unicode.c:143:3: danger: argument 1 ('ret') from [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
#  141|     int ret_len = ucs2_strlen((uint16_t*)unicstr)*sizeof(uint16_t)+2;
#  142|     uint16_t* ret = malloc(ret_len);
#  143|->   memcpy(ret,unicstr,(size_t)ret_len);
#  144|     return ret;
#  145|   }

Error: COMPILER_WARNING (CWE-1023): [#def322]
libmtp-1.1.22/util/mtp-hotplug.c: scope_hint: In function ‘main’
libmtp-1.1.22/util/mtp-hotplug.c:233:7: warning[-Wswitch]: enumeration value ‘style_udev’ not handled in switch
#  233 |       switch (style) {
#      |       ^~~~~~
#  231|         LIBMTP_device_entry_t * entry = &entries[i];
#  232|   
#  233|->       switch (style) {
#  234|         case style_udev_fast:
#  235|   	entry = &entries[sorted_codes[i]];

Error: GCC_ANALYZER_WARNING (CWE-775): [#def323]
libmtp-1.1.22/util/mtp-probe.c:87:3: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&pbuf, 0)’
libmtp-1.1.22/util/mtp-probe.c:83:8: acquire_resource: opened here
libmtp-1.1.22/util/mtp-probe.c:84:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:86:11: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:87:3: danger: ‘open(&pbuf, 0)’ leaks here; was opened at [(2)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/1)
#   85|       return OTHER_EP;
#   86|     bread = read(fd, buf, sizeof(buf));
#   87|->   close(fd);
#   88|     if (bread < 2)
#   89|       return OTHER_EP;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def324]
libmtp-1.1.22/util/mtp-probe.c:108:3: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&pbuf, 0)’
libmtp-1.1.22/util/mtp-probe.c:84:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:86:11: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:88:6: branch_false: following ‘false’ branch (when ‘bread > 1’)...
libmtp-1.1.22/util/mtp-probe.c:88:6: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:91:15: branch_true: following ‘true’ branch (when ‘i < bread’)...
libmtp-1.1.22/util/mtp-probe.c:92:8: branch_true: ...to here
libmtp-1.1.22/util/mtp-probe.c:104:8: acquire_resource: opened here
libmtp-1.1.22/util/mtp-probe.c:105:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:107:11: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:108:3: danger: ‘open(&pbuf, 0)’ leaks here; was opened at [(9)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/8)
#  106|       return OTHER_EP;
#  107|     bread = read(fd, buf, sizeof(buf));
#  108|->   close(fd);
#  109|     if (bread < 2)
#  110|       return OTHER_EP;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def325]
libmtp-1.1.22/util/mtp-probe.c:151:3: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&pbuf, 0)’
libmtp-1.1.22/util/mtp-probe.c:146:8: acquire_resource: opened here
libmtp-1.1.22/util/mtp-probe.c:147:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:150:11: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:151:3: danger: ‘open(&pbuf, 0)’ leaks here; was opened at [(2)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/1)
#  149|     /* Read all contents to buffer */
#  150|     bread = read(fd, buf, sizeof(buf));
#  151|->   close(fd);
#  152|     if (bread < 2)
#  153|       return 0;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def326]
libmtp-1.1.22/util/mtp-probe.c:187:9: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(sysfspath)’
libmtp-1.1.22/util/mtp-probe.c:162:12: enter_function: entry to ‘check_interface’
libmtp-1.1.22/util/mtp-probe.c:174:9: call_function: calling ‘has_3_ep’ from ‘check_interface’
libmtp-1.1.22/util/mtp-probe.c:174:9: return_function: returning to ‘check_interface’ from ‘has_3_ep’
libmtp-1.1.22/util/mtp-probe.c:175:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:179:9: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:179:9: acquire_memory: allocated here
libmtp-1.1.22/util/mtp-probe.c:180:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:183:3: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:187:9: throw: if ‘regcomp’ throws an exception...
libmtp-1.1.22/util/mtp-probe.c:187:9: danger: ‘opendir(sysfspath)’ leaks here; was allocated at [(8)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/7)
#  185|   
#  186|     /* Check for dirs that identify endpoints */
#  187|->   ret = regcomp(&r, "^ep_[0-9a-f]+$", REG_EXTENDED | REG_NOSUB);
#  188|     if (ret) {
#  189|       closedir(dir);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def327]
libmtp-1.1.22/util/mtp-probe.c:189:5: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(sysfspath)’
libmtp-1.1.22/util/mtp-probe.c:162:12: enter_function: entry to ‘check_interface’
libmtp-1.1.22/util/mtp-probe.c:174:9: call_function: calling ‘has_3_ep’ from ‘check_interface’
libmtp-1.1.22/util/mtp-probe.c:174:9: return_function: returning to ‘check_interface’ from ‘has_3_ep’
libmtp-1.1.22/util/mtp-probe.c:175:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:179:9: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:179:9: acquire_memory: allocated here
libmtp-1.1.22/util/mtp-probe.c:180:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:183:3: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:188:6: branch_true: following ‘true’ branch...
libmtp-1.1.22/util/mtp-probe.c:189:5: branch_true: ...to here
libmtp-1.1.22/util/mtp-probe.c:189:5: danger: ‘opendir(sysfspath)’ leaks here; was allocated at [(8)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/7)
#  187|     ret = regcomp(&r, "^ep_[0-9a-f]+$", REG_EXTENDED | REG_NOSUB);
#  188|     if (ret) {
#  189|->     closedir(dir);
#  190|       return -1;
#  191|     }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def328]
libmtp-1.1.22/util/mtp-probe.c:193:18: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(sysfspath)’
libmtp-1.1.22/util/mtp-probe.c:162:12: enter_function: entry to ‘check_interface’
libmtp-1.1.22/util/mtp-probe.c:174:9: call_function: calling ‘has_3_ep’ from ‘check_interface’
libmtp-1.1.22/util/mtp-probe.c:174:9: return_function: returning to ‘check_interface’ from ‘has_3_ep’
libmtp-1.1.22/util/mtp-probe.c:175:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:179:9: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:179:9: acquire_memory: allocated here
libmtp-1.1.22/util/mtp-probe.c:180:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:183:3: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:188:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:188:6: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:193:18: throw: if ‘readdir’ throws an exception...
libmtp-1.1.22/util/mtp-probe.c:193:18: danger: ‘opendir(sysfspath)’ leaks here; was allocated at [(8)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/7)
#  191|     }
#  192|   
#  193|->   while ((dent = readdir(dir))) {
#  194|       struct stat st;
#  195|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def329]
libmtp-1.1.22/util/mtp-probe.c:251:9: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(sysfspath)’
libmtp-1.1.22/util/mtp-probe.c:243:9: acquire_memory: allocated here
libmtp-1.1.22/util/mtp-probe.c:244:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:247:3: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:251:9: throw: if ‘regcomp’ throws an exception...
libmtp-1.1.22/util/mtp-probe.c:251:9: danger: ‘opendir(sysfspath)’ leaks here; was allocated at [(1)](sarif:/runs/0/results/6/codeFlows/0/threadFlows/0/locations/0)
#  249|   
#  250|     /* Check for dirs that identify interfaces */
#  251|->   ret = regcomp(&r, "^[0-9]+-[0-9]+(\\.[0-9])*\\:[0-9]+\\.[0-9]+$", REG_EXTENDED | REG_NOSUB);
#  252|     if (ret) {
#  253|       closedir(dir);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def330]
libmtp-1.1.22/util/mtp-probe.c:253:5: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(sysfspath)’
libmtp-1.1.22/util/mtp-probe.c:243:9: acquire_memory: allocated here
libmtp-1.1.22/util/mtp-probe.c:244:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:247:3: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:252:6: branch_true: following ‘true’ branch...
libmtp-1.1.22/util/mtp-probe.c:253:5: branch_true: ...to here
libmtp-1.1.22/util/mtp-probe.c:253:5: danger: ‘opendir(sysfspath)’ leaks here; was allocated at [(1)](sarif:/runs/0/results/7/codeFlows/0/threadFlows/0/locations/0)
#  251|     ret = regcomp(&r, "^[0-9]+-[0-9]+(\\.[0-9])*\\:[0-9]+\\.[0-9]+$", REG_EXTENDED | REG_NOSUB);
#  252|     if (ret) {
#  253|->     closedir(dir);
#  254|       return -1;
#  255|     }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def331]
libmtp-1.1.22/util/mtp-probe.c:257:18: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(sysfspath)’
libmtp-1.1.22/util/mtp-probe.c:243:9: acquire_memory: allocated here
libmtp-1.1.22/util/mtp-probe.c:244:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:247:3: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:252:6: branch_false: following ‘false’ branch...
libmtp-1.1.22/util/mtp-probe.c:252:6: branch_false: ...to here
libmtp-1.1.22/util/mtp-probe.c:257:18: throw: if ‘readdir’ throws an exception...
libmtp-1.1.22/util/mtp-probe.c:257:18: danger: ‘opendir(sysfspath)’ leaks here; was allocated at [(1)](sarif:/runs/0/results/8/codeFlows/0/threadFlows/0/locations/0)
#  255|     }
#  256|   
#  257|->   while ((dent = readdir(dir))) {
#  258|       struct stat st;
#  259|       int ret;

Scan Properties

analyzer-version-clippy1.92.0
analyzer-version-cppcheck2.19.1
analyzer-version-gcc16.0.0
analyzer-version-gcc-analyzer16.0.0
analyzer-version-shellcheck0.11.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-39.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20250521.132812.g8eff701.main-1.el9.noarch
mock-configfedora-rawhide-x86_64
project-namelibmtp-1.1.22-1.fc44
store-results-to/tmp/tmp5j2br0pd/libmtp-1.1.22-1.fc44.tar.xz
time-created2026-01-08 19:01:20
time-finished2026-01-08 19:03:26
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'gcc,cppcheck,clippy,shellcheck,unicontrol' '-o' '/tmp/tmp5j2br0pd/libmtp-1.1.22-1.fc44.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmp5j2br0pd/libmtp-1.1.22-1.fc44.src.rpm'
tool-versioncsmock-3.8.3.20251215.161544.g62de9a5-1.el9