Blame SOURCES/gdbm-sa1.patch

ec97eb
These issues have been found by Coverty static analysis tool:
ec97eb
ec97eb
Error: RESOURCE_LEAK (CWE-404): [#def4]
ec97eb
gdbm-1.10/src/flatfile.c:40: switch: Switch case value "2"
ec97eb
gdbm-1.10/src/flatfile.c:42: switch_case: Reached case "2"
ec97eb
gdbm-1.10/src/flatfile.c:43: open_fn: Returning handle opened by function "open(char const *, int, ...)".
ec97eb
gdbm-1.10/src/flatfile.c:43: var_assign: Assigning: "nfd" = handle returned from "open(exportfile, 193, mode)".
ec97eb
gdbm-1.10/src/flatfile.c:44: cond_false: Condition "nfd == -1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:48: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:49: break: Breaking from switch
ec97eb
gdbm-1.10/src/flatfile.c:65: switch_end: Reached end of switch
ec97eb
gdbm-1.10/src/flatfile.c:68: noescape: Resource "nfd" is not freed or pointed-to in function "write(int, void const *, size_t)".
ec97eb
gdbm-1.10/src/flatfile.c:68: cond_true: Condition "write(nfd, header1, strlen(header1)) != strlen(header1)", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:69: goto: Jumping to label "write_fail"
ec97eb
gdbm-1.10/src/flatfile.c:107: label: Reached label "write_fail"
ec97eb
gdbm-1.10/src/flatfile.c:110: leaked_handle: Handle variable "nfd" going out of scope leaks the handle.
ec97eb
ec97eb
Error: RESOURCE_LEAK (CWE-404): [#def5]
ec97eb
gdbm-1.10/src/flatfile.c:40: switch: Switch case value "3"
ec97eb
gdbm-1.10/src/flatfile.c:50: switch_case: Reached case "3"
ec97eb
gdbm-1.10/src/flatfile.c:51: open_fn: Returning handle opened by function "open(char const *, int, ...)".
ec97eb
gdbm-1.10/src/flatfile.c:51: var_assign: Assigning: "nfd" = handle returned from "open(exportfile, 577, mode)".
ec97eb
gdbm-1.10/src/flatfile.c:52: cond_false: Condition "nfd == -1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:56: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:57: break: Breaking from switch
ec97eb
gdbm-1.10/src/flatfile.c:65: switch_end: Reached end of switch
ec97eb
gdbm-1.10/src/flatfile.c:68: noescape: Resource "nfd" is not freed or pointed-to in function "write(int, void const *, size_t)".
ec97eb
gdbm-1.10/src/flatfile.c:68: cond_true: Condition "write(nfd, header1, strlen(header1)) != strlen(header1)", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:69: goto: Jumping to label "write_fail"
ec97eb
gdbm-1.10/src/flatfile.c:107: label: Reached label "write_fail"
ec97eb
gdbm-1.10/src/flatfile.c:110: leaked_handle: Handle variable "nfd" going out of scope leaks the handle.
ec97eb
ec97eb
Error: RESOURCE_LEAK (CWE-404): [#def6]
ec97eb
gdbm-1.10/src/flatfile.c:124: cond_false: Condition "ifd == -1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:128: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_false: Condition "seennewline > 2", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:149: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_false: Condition "seennewline > 2", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:149: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seennewline > 2", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:148: break: Breaking from loop
ec97eb
gdbm-1.10/src/flatfile.c:152: loop_end: Reached end of loop
ec97eb
gdbm-1.10/src/flatfile.c:156: alloc_fn: Storage is returned from allocation function "malloc(size_t)".
ec97eb
gdbm-1.10/src/flatfile.c:156: var_assign: Assigning: "kbuffer" = storage returned from "malloc(kbufsize)".
ec97eb
gdbm-1.10/src/flatfile.c:157: cond_false: Condition "kbuffer == NULL", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:162: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:165: cond_true: Condition "dbuffer == NULL", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:169: leaked_storage: Variable "kbuffer" going out of scope leaks the storage it points to.
ec97eb
ec97eb
Error: RESOURCE_LEAK (CWE-404): [#def8]
ec97eb
gdbm-1.10/src/flatfile.c:124: cond_false: Condition "ifd == -1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:128: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_false: Condition "seennewline > 2", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:149: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_false: Condition "seennewline > 2", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:149: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seennewline > 2", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:148: break: Breaking from loop
ec97eb
gdbm-1.10/src/flatfile.c:152: loop_end: Reached end of loop
ec97eb
gdbm-1.10/src/flatfile.c:157: cond_false: Condition "kbuffer == NULL", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:162: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:164: alloc_fn: Storage is returned from allocation function "malloc(size_t)".
ec97eb
gdbm-1.10/src/flatfile.c:164: var_assign: Assigning: "dbuffer" = storage returned from "malloc(dbufsize)".
ec97eb
gdbm-1.10/src/flatfile.c:165: cond_false: Condition "dbuffer == NULL", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:170: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:173: cond_true: Condition "(rret = read(ifd, &rsize, 4UL /* sizeof (rsize) */)) != 0", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:175: cond_false: Condition "rret != 4UL /* sizeof (rsize) */", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:176: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:180: cond_true: Condition "size > kbufsize", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:184: cond_true: Condition "kbuffer == NULL", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:188: leaked_storage: Variable "dbuffer" going out of scope leaks the storage it points to.
ec97eb
ec97eb
Error: RESOURCE_LEAK (CWE-404): [#def9]
ec97eb
gdbm-1.10/src/flatfile.c:124: cond_false: Condition "ifd == -1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:128: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_false: Condition "seennewline > 2", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:149: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_true: Condition "c == '!'", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_false: Condition "c == 10", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:151: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_false: Condition "seennewline > 2", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:149: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:152: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/flatfile.c:136: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/flatfile.c:136: cond_true: Condition "1", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:138: cond_false: Condition "read(ifd, &c, 1) != 1", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:139: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:141: cond_false: Condition "c == '!'", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:142: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:143: cond_true: Condition "c == 10", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seenbang > 3", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:145: cond_true: Condition "seennewline > 2", taking true branch
ec97eb
gdbm-1.10/src/flatfile.c:148: break: Breaking from loop
ec97eb
gdbm-1.10/src/flatfile.c:152: loop_end: Reached end of loop
ec97eb
gdbm-1.10/src/flatfile.c:157: cond_false: Condition "kbuffer == NULL", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:162: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:164: alloc_fn: Storage is returned from allocation function "malloc(size_t)".
ec97eb
gdbm-1.10/src/flatfile.c:164: var_assign: Assigning: "dbuffer" = storage returned from "malloc(dbufsize)".
ec97eb
gdbm-1.10/src/flatfile.c:165: cond_false: Condition "dbuffer == NULL", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:170: if_end: End of if statement
ec97eb
gdbm-1.10/src/flatfile.c:173: cond_false: Condition "(rret = read(ifd, &rsize, 4UL /* sizeof (rsize) */)) != 0", taking false branch
ec97eb
gdbm-1.10/src/flatfile.c:229: loop_end: Reached end of loop
ec97eb
gdbm-1.10/src/flatfile.c:232: leaked_storage: Variable "dbuffer" going out of scope leaks the storage it points to.
ec97eb
ec97eb
Error: USE_AFTER_FREE (CWE-416): [#def16]
ec97eb
gdbm-1.10/src/gdbmreorg.c:70: cond_false: Condition "dbf->read_write == 0", taking false branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:74: if_end: End of if statement
ec97eb
gdbm-1.10/src/gdbmreorg.c:77: cond_false: Condition "fstat(dbf->desc, &fileinfo)", taking false branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:81: if_end: End of if statement
ec97eb
gdbm-1.10/src/gdbmreorg.c:89: cond_false: Condition "new_name == NULL", taking false branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:93: if_end: End of if statement
ec97eb
gdbm-1.10/src/gdbmreorg.c:97: cond_true: Condition "len > 0", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:97: cond_true: Condition "new_name[len - 1] != '/'", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:101: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/gdbmreorg.c:97: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/gdbmreorg.c:97: cond_true: Condition "len > 0", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:97: cond_false: Condition "new_name[len - 1] != '/'", taking false branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:101: loop_end: Reached end of loop
ec97eb
gdbm-1.10/src/gdbmreorg.c:105: cond_true: Condition "dbf->cloexec", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:109: cond_false: Condition "new_dbf == NULL", taking false branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:114: if_end: End of if statement
ec97eb
gdbm-1.10/src/gdbmreorg.c:120: cond_false: Condition "key.dptr != NULL", taking false branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:148: loop_end: Reached end of loop
ec97eb
gdbm-1.10/src/gdbmreorg.c:160: cond_false: Condition "rename(new_name, dbf->name) != 0", taking false branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:166: if_end: End of if statement
ec97eb
gdbm-1.10/src/gdbmreorg.c:169: cond_true: Condition "dbf->file_locking", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:173: closed_arg: "close(int)" closes "dbf->desc".
ec97eb
gdbm-1.10/src/gdbmreorg.c:177: cond_true: Condition "dbf->bucket_cache != NULL", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:178: cond_true: Condition "index < dbf->cache_size", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:179: cond_true: Condition "(dbf->bucket_cache + index).ca_bucket != NULL", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:181: cond_true: Condition "(dbf->bucket_cache + index).ca_data.dptr != NULL", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:183: loop: Jumping back to the beginning of the loop
ec97eb
gdbm-1.10/src/gdbmreorg.c:178: loop_begin: Jumped back to beginning of loop
ec97eb
gdbm-1.10/src/gdbmreorg.c:178: cond_false: Condition "index < dbf->cache_size", taking false branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:183: loop_end: Reached end of loop
ec97eb
gdbm-1.10/src/gdbmreorg.c:189: cond_true: Condition "dbf->memory_mapping", taking true branch
ec97eb
gdbm-1.10/src/gdbmreorg.c:190: pass_closed_arg: Passing closed handle "dbf->desc" as an argument to function "_gdbm_mapped_init(GDBM_FILE)".
ec97eb
ec97eb
ec97eb
ec97eb
diff -up gdbm-1.10/src/flatfile.c.sa1 gdbm-1.10/src/flatfile.c
ec97eb
--- gdbm-1.10/src/flatfile.c.sa1	2012-12-10 15:45:41.835009811 +0100
ec97eb
+++ gdbm-1.10/src/flatfile.c	2012-12-10 15:55:22.650480928 +0100
ec97eb
@@ -106,6 +106,7 @@ gdbm_export (GDBM_FILE dbf, const char *
ec97eb
   
ec97eb
  write_fail:
ec97eb
   
ec97eb
+  close (nfd);
ec97eb
   gdbm_errno = GDBM_FILE_WRITE_ERROR;
ec97eb
   return -1;
ec97eb
 }
ec97eb
@@ -166,6 +167,7 @@ gdbm_import (GDBM_FILE dbf, const char *
ec97eb
     {
ec97eb
       gdbm_errno = GDBM_MALLOC_ERROR;
ec97eb
       close (ifd);
ec97eb
+      free(kbuffer);
ec97eb
       return -1;
ec97eb
     }
ec97eb
 
ec97eb
@@ -185,6 +187,7 @@ gdbm_import (GDBM_FILE dbf, const char *
ec97eb
 	    {
ec97eb
 	      gdbm_errno = GDBM_MALLOC_ERROR;
ec97eb
 	      close (ifd);
ec97eb
+	      free(dbuffer);
ec97eb
 	      return -1;
ec97eb
 	    }
ec97eb
 	}
ec97eb
@@ -228,6 +231,11 @@ gdbm_import (GDBM_FILE dbf, const char *
ec97eb
       count++;
ec97eb
     }
ec97eb
 
ec97eb
+  if (kbuffer != NULL)
ec97eb
+    free (kbuffer);
ec97eb
+  if (dbuffer != NULL)
ec97eb
+    free (dbuffer);
ec97eb
+
ec97eb
   close (ifd);
ec97eb
   return count;
ec97eb
 
ec97eb
diff -up gdbm-1.10/src/gdbmreorg.c.sa1 gdbm-1.10/src/gdbmreorg.c
ec97eb
--- gdbm-1.10/src/gdbmreorg.c.sa1	2012-12-10 16:12:23.818314970 +0100
ec97eb
+++ gdbm-1.10/src/gdbmreorg.c	2012-12-10 16:12:30.947320804 +0100
ec97eb
@@ -184,12 +184,6 @@ gdbm_reorganize (GDBM_FILE dbf)
ec97eb
     free (dbf->bucket_cache);
ec97eb
   }
ec97eb
 
ec97eb
-#if HAVE_MMAP
ec97eb
-  /* Re-initialize mapping if required */
ec97eb
-  if (dbf->memory_mapping)
ec97eb
-    _gdbm_mapped_init (dbf);
ec97eb
-#endif
ec97eb
-  
ec97eb
   dbf->desc           = new_dbf->desc;
ec97eb
   dbf->header         = new_dbf->header;
ec97eb
   dbf->dir            = new_dbf->dir;
ec97eb
@@ -203,6 +197,12 @@ gdbm_reorganize (GDBM_FILE dbf)
ec97eb
   dbf->bucket_changed    = new_dbf->bucket_changed;
ec97eb
   dbf->second_changed    = new_dbf->second_changed;
ec97eb
    
ec97eb
+#if HAVE_MMAP
ec97eb
+  /* Re-initialize mapping if required */
ec97eb
+  if (dbf->memory_mapping)
ec97eb
+    _gdbm_mapped_init (dbf);
ec97eb
+#endif
ec97eb
+  
ec97eb
   free (new_dbf->name);   
ec97eb
   free (new_dbf);
ec97eb
   free (new_name);