Skip to content

crypt_gensalt_ra: Avoid memory leak in case of crypt_gensalt_rn error#19

Merged
zackw merged 1 commit intobesser82:developfrom
fweimer:develop
Jul 24, 2018
Merged

crypt_gensalt_ra: Avoid memory leak in case of crypt_gensalt_rn error#19
zackw merged 1 commit intobesser82:developfrom
fweimer:develop

Conversation

@fweimer
Copy link
Contributor

@fweimer fweimer commented Jul 24, 2018

This was reported by clang.

Error: CLANG_WARNING: [#def6]
libxcrypt-4.1.0/crypt.c:415:3: warning: Potential leak of memory pointed to by 'output'
#  return crypt_gensalt_rn (prefix, count, rbytes, nrbytes, output,
#  ^
libxcrypt-4.1.0/crypt.c:411:18: note: Memory is allocated
#  char *output = malloc (CRYPT_GENSALT_OUTPUT_SIZE);
#                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libxcrypt-4.1.0/crypt.c:412:7: note: Assuming 'output' is non-null
#  if (!output)
#      ^~~~~~~
libxcrypt-4.1.0/crypt.c:412:3: note: Taking false branch
#  if (!output)
#  ^
libxcrypt-4.1.0/crypt.c:415:3: note: Potential leak of memory pointed to by 'output'
#  return crypt_gensalt_rn (prefix, count, rbytes, nrbytes, output,
#  ^
#  413|       return 0;
#  414|   
#  415|->   return crypt_gensalt_rn (prefix, count, rbytes, nrbytes, output,
#  416|                              CRYPT_GENSALT_OUTPUT_SIZE);
#  417|   }

@codecov-io
Copy link

codecov-io commented Jul 24, 2018

Codecov Report

Merging #19 into develop will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #19      +/-   ##
===========================================
+ Coverage    97.07%   97.07%   +<.01%     
===========================================
  Files           22       22              
  Lines         1949     1952       +3     
===========================================
+ Hits          1892     1895       +3     
  Misses          57       57
Impacted Files Coverage Δ
crypt.c 95% <100%> (+0.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 492b7fa...7093a8e. Read the comment docs.

@zackw zackw merged commit 1d7efe5 into besser82:develop Jul 24, 2018
@zackw
Copy link
Collaborator

zackw commented Jul 24, 2018

Nice catch! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants