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

gcc static analyzer findings #2

Open
chipitsine opened this issue Aug 20, 2020 · 0 comments
Open

gcc static analyzer findings #2

chipitsine opened this issue Aug 20, 2020 · 0 comments

Comments

@chipitsine
Copy link
Contributor

src/libhercules.c: In function ‘vector_add_Byte’:
src/libhercules.c:486:13: warning: dereference of possibly-NULL ‘v_byte’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  486 |     *v_byte = value;
      |     ~~~~~~~~^~~~~~~
  ‘vector_add_Byte’: events 1-2
    |
    |  485 |     uint8_t* v_byte = malloc(sizeof(uint8_t));
    |      |                       ^~~~~~~~~~~~~~~~~~~~~~~
    |      |                       |
    |      |                       (1) this call could return NULL
    |  486 |     *v_byte = value;
    |      |     ~~~~~~~~~~~~~~~    
    |      |             |
    |      |             (2) ‘v_byte’ could be NULL: unchecked value from (1)
    |
src/libhercules.c: In function ‘vector_add_Short’:
src/libhercules.c:492:14: warning: dereference of possibly-NULL ‘v_short’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  492 |     *v_short = value;
      |     ~~~~~~~~~^~~~~~~
  ‘vector_add_Short’: events 1-2
    |
    |  491 |     int16_t* v_short = malloc(sizeof(int16_t));
    |      |                        ^~~~~~~~~~~~~~~~~~~~~~~
    |      |                        |
    |      |                        (1) this call could return NULL
    |  492 |     *v_short = value;
    |      |     ~~~~~~~~~~~~~~~~    
    |      |              |
    |      |              (2) ‘v_short’ could be NULL: unchecked value from (1)
    |
src/libhercules.c: In function ‘vector_add_Integer’:
src/libhercules.c:498:16: warning: dereference of possibly-NULL ‘v_integer’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  498 |     *v_integer = value;
      |     ~~~~~~~~~~~^~~~~~~
  ‘vector_add_Integer’: events 1-2
    |
    |  497 |     int32_t* v_integer = malloc(sizeof(int32_t));
    |      |                          ^~~~~~~~~~~~~~~~~~~~~~~
    |      |                          |
    |      |                          (1) this call could return NULL
    |  498 |     *v_integer = value;
    |      |     ~~~~~~~~~~~~~~~~~~    
    |      |                |
    |      |                (2) ‘v_integer’ could be NULL: unchecked value from (1)
    |
src/libhercules.c: In function ‘vector_add_Long’:
src/libhercules.c:504:13: warning: dereference of possibly-NULL ‘v_long’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  504 |     *v_long = value;
      |     ~~~~~~~~^~~~~~~
  ‘vector_add_Long’: events 1-2
    |
    |  503 |     int64_t* v_long = malloc(sizeof(int64_t));
    |      |                       ^~~~~~~~~~~~~~~~~~~~~~~
    |      |                       |
    |      |                       (1) this call could return NULL
    |  504 |     *v_long = value;
    |      |     ~~~~~~~~~~~~~~~    
    |      |             |
    |      |             (2) ‘v_long’ could be NULL: unchecked value from (1)
    |
src/libhercules.c: In function ‘vector_add_Flag’:
src/libhercules.c:510:13: warning: dereference of possibly-NULL ‘v_flag’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  510 |     *v_flag = value;
      |     ~~~~~~~~^~~~~~~
  ‘vector_add_Flag’: events 1-2
    |
    |  509 |     char* v_flag = malloc(sizeof(char));
    |      |                    ^~~~~~~~~~~~~~~~~~~~
    |      |                    |
    |      |                    (1) this call could return NULL
    |  510 |     *v_flag = value;
    |      |     ~~~~~~~~~~~~~~~ 
    |      |             |
    |      |             (2) ‘v_flag’ could be NULL: unchecked value from (1)
    |
src/libhercules.c: In function ‘vector_add_Float’:
src/libhercules.c:516:14: warning: dereference of possibly-NULL ‘v_float’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  516 |     *v_float = value;
      |     ~~~~~~~~~^~~~~~~
  ‘vector_add_Float’: events 1-2
    |
    |  515 |     float* v_float = malloc(sizeof(float));
    |      |                      ^~~~~~~~~~~~~~~~~~~~~
    |      |                      |
    |      |                      (1) this call could return NULL
    |  516 |     *v_float = value;
    |      |     ~~~~~~~~~~~~~~~~  
    |      |              |
    |      |              (2) ‘v_float’ could be NULL: unchecked value from (1)
    |
src/libhercules.c: In function ‘vector_add_Double’:
src/libhercules.c:522:15: warning: dereference of possibly-NULL ‘v_double’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  522 |     *v_double = value;
      |     ~~~~~~~~~~^~~~~~~
  ‘vector_add_Double’: events 1-2
    |
    |  521 |     double* v_double = malloc(sizeof(double));
    |      |                        ^~~~~~~~~~~~~~~~~~~~~~
    |      |                        |
    |      |                        (1) this call could return NULL
    |  522 |     *v_double = value;
    |      |     ~~~~~~~~~~~~~~~~~   
    |      |               |
    |      |               (2) ‘v_double’ could be NULL: unchecked value from (1)
    |
src/libhercules.c: In function ‘vector_add_String’:
src/libhercules.c:528:5: warning: use of possibly-NULL ‘v_string’ where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]
  528 |     strcpy(v_string, value);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
  ‘vector_add_String’: events 1-2
    |
    |  527 |     char* v_string = malloc(sizeof(char) * strlen(value));
    |      |                                            ^~~~~~~~~~~~~
    |      |                                            |
    |      |                                            (1) this call could return NULL
    |  528 |     strcpy(v_string, value);
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~                 
    |      |     |
    |      |     (2) argument 1 (‘v_string’) from (1) could be NULL where non-null expected
    |
In file included from src/libhercules.c:3:
/usr/include/string.h:122:14: note: argument 1 of ‘strcpy’ must be non-null
  122 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
      |              ^~~~~~
src/libhercules.c: In function ‘vector_add_UUID’:
src/libhercules.c:534:5: warning: dereference of possibly-NULL ‘v_uuid’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  534 |     memcpy(v_uuid, value, 16);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
  ‘vector_add_UUID’: events 1-2
    |
    |  533 |     uint8_t* v_uuid = malloc(sizeof(uint8_t) * 16);
    |      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                       |
    |      |                       (1) this call could return NULL
    |  534 |     memcpy(v_uuid, value, 16);
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |     |
    |      |     (2) ‘v_uuid’ could be NULL: unchecked value from (1)
    |
src/libhercules.c: In function ‘vector_add_Vector’:
src/libhercules.c:540:24: warning: dereference of possibly-NULL ‘v_vector’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  540 |     v_vector->datatype = datatype;
      |     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
  ‘vector_add_Vector’: events 1-2
    |
    |  539 |     Vector* v_vector = malloc(sizeof(Vector));
    |      |                        ^~~~~~~~~~~~~~~~~~~~~~
    |      |                        |
    |      |                        (1) this call could return NULL
    |  540 |     v_vector->datatype = datatype;
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                        |
    |      |                        (2) ‘v_vector’ could be NULL: unchecked value from (1)
    |

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

No branches or pull requests

1 participant