Skip to content
Snippets Groups Projects
Commit eb322705 authored by Kamil Dudka's avatar Kamil Dudka
Browse files

allocateHash: fix incorrect sizeof computation (#149)

This was supposed to be fixed by 3.12.3-21-g8523cb3 but it was not
because there was a typo sizeof(sizeof ...) and even after fixing
the typo it referred to the pointer size, instead of struct size.

Luckily, this was detected by Clang analyzer again.  Now I verified
that the defect goes away with this commit:

FIXED DEFECTS
=============
Error: CLANG_WARNING:
logrotate.c:249:15: warning: Result of 'malloc' is converted to a pointer of type 'struct logStateList', which is incompatible with sizeof operand type 'unsigned long'
parent d85c496f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -246,7 +246,7 @@ static int allocateHash(unsigned int hs)
}
 
for (i = 0; i < hs; i++) {
states[i] = malloc(sizeof(sizeof states[i]));
states[i] = malloc(sizeof *states[0]);
if (states[i] == NULL) {
message(MESS_ERROR, "could not allocate memory for "
"hash element\n");
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment