Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug reports from clang-analyzer #70

Closed
furuame opened this issue Sep 15, 2018 · 2 comments
Closed

Bug reports from clang-analyzer #70

furuame opened this issue Sep 15, 2018 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@furuame
Copy link
Member

furuame commented Sep 15, 2018

scan-build: Using '/usr/lib/llvm-6.0/bin/clang' for static analysis
  CC    build/curl.o
  CC    build/constants.o
  CC    build/trinary.o
  CC    build/dcurl.o
  CC    build/implcontext.o
  CC    build/pow_sse.o
src/pow_sse.c:287:16: warning: Potential leak of memory pointed to by 'c_state'
        return NULL;
               ^~~~
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/stddef.h:105:24: note: expanded from macro 'NULL'
#  define NULL ((void*)0)
                       ^
src/pow_sse.c:355:16: warning: Potential leak of memory pointed to by 'c_state'
        return false;
               ^~~~~
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdbool.h:33:15: note: expanded from macro 'false'
#define false 0
              ^
src/pow_sse.c:376:42: warning: Result of 'malloc' is converted to a pointer of type 'int8_t *', which is incompatible with sizeof operand type 'int *'
        ctx[i].nonce_array = (int8_t **) malloc(sizeof(int *) * nproc);
                              ~~~~~~~~~  ^~~~~~ ~~~~~~~~~~~~~
src/pow_sse.c:378:87: warning: Potential leak of memory pointed to by 'chunk'
        if (!ctx[i].threads || !ctx[i].pitem || !ctx[i].nonce_array || !chunk) return false;
                                                                                      ^~~~~
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdbool.h:33:15: note: expanded from macro 'false'
#define false 0
              ^
src/pow_sse.c:378:87: warning: Potential leak of memory pointed to by 'ctx'
        if (!ctx[i].threads || !ctx[i].pitem || !ctx[i].nonce_array || !chunk) return false;
                                                                                      ^~~~~
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdbool.h:33:15: note: expanded from macro 'false'
#define false 0
              ^
5 warnings generated.
@furuame furuame self-assigned this Sep 15, 2018
@furuame furuame added the bug Something isn't working label Sep 15, 2018
@furuame
Copy link
Member Author

furuame commented Sep 15, 2018

@ajblane I found that the fpga implementation also has similar issue. Could you help fix it and send me a PR? Because I do not have a FPGA board to do testing.

For example:

if (!object_trits)

The trytes object_trytes at line 36 won't be freed if branch taken at line 42.

You can reference the branch fix-memory-leak, in which I fix the SSE implementation.

furuame added a commit that referenced this issue Sep 16, 2018
@furuame
Copy link
Member Author

furuame commented Sep 16, 2018

@ajblane I found that the fpga implementation also has similar issue. Could you help fix it and send me a PR? Because I do not have a FPGA board to do testing.

For example:

dcurl/src/pow_fpga_accel.c

Line 42 in 5d41f9e
if (!object_trits)

The trytes object_trytes at line 36 won't be freed if branch taken at line 42.

You can reference the branch fix-memory-leak, in which I fix the SSE implementation.

Fixed by myself.

@jserv jserv closed this as completed in 0544e57 Sep 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant