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

[CWE-401] gl4du.c newGL4DUMatrix call in gl4duGenMatrix #14

Open
darnuria opened this issue Oct 24, 2020 · 3 comments
Open

[CWE-401] gl4du.c newGL4DUMatrix call in gl4duGenMatrix #14

darnuria opened this issue Oct 24, 2020 · 3 comments

Comments

@darnuria
Copy link
Collaborator

Reproduction comme dans: #11 merci gcc10 avec -fanalyzer, c'est un malloc-leak.

GL4D/gl4du.c: In functionnewGL4DUMatrix’:
GL4D/gl4du.c:916:10: warning: leak of<unknown>’ [CWE-401] [-Wanalyzer-malloc-leak]
  916 |   return m;
      |          ^
  ‘gl4duGenMatrix’: events 1-4
    |
    |  979 | GLboolean gl4duGenMatrix(GLenum type, const char * name) {
    |      |           ^~~~~~~~~~~~~~
    |      |           |
    |      |           (1) entry togl4duGenMatrix’
    |......
    |  984 |   if(pair.compResult) {
    |      |     ~      
    |      |     |
    |      |     (2) following ‘true’ branch...
    |  985 |     p = newGL4DUMatrix(type, name);
    |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |         |
    |      |         (3) ...to here
    |      |         (4) callingnewGL4DUMatrixfromgl4duGenMatrix’
    |
    +-->newGL4DUMatrix’: event 5
           |
           |  906 | static inline _GL4DUMatrix * newGL4DUMatrix(GLenum type, const char * name) {
           |      |                              ^~~~~~~~~~~~~~
           |      |                              |
           |      |                              (5) entry tonewGL4DUMatrix’
           |
         ‘newGL4DUMatrix’: event 6
           |
           |  908 |   assert(m);
           |      |   ^~~~~~
           |      |   |
           |      |   (6) following ‘true’ branch (whenmis non-NULL)...
           |
         ‘newGL4DUMatrix’: events 7-8
           |
           |  909 |   m->name  = strdup(name);
           |      |              ^~~~~~~~~~~~
           |      |              |
           |      |              (7) ...to here
           |  910 |   m->type  = type;
           |  911 |   m->size  = 16 * ( (type == GL_FLOAT) ? sizeof (GLfloat) : /* type == GL_DOUBLE */ sizeof (GLdouble) );
           |      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |                 |
           |      |                 (8) following ‘false’ branch (whentype != 5126’)...
           |
         ‘newGL4DUMatrix’: event 9
           |
           |cc1:
           | (9): ...to here
           |
         ‘newGL4DUMatrix’: event 10
           |
           |  911 |   m->size  = 16 * ( (type == GL_FLOAT) ? sizeof (GLfloat) : /* type == GL_DOUBLE */ sizeof (GLdouble) );
           |      |   ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |            |
           |      |            (10) allocated here
           |
         ‘newGL4DUMatrix’: event 11
           |
           |  915 |   assert(m->data);
           |      |   ^~~~~~
           |      |   |
           |      |   (11) assuming<unknown>is non-NULL
           |
         ‘newGL4DUMatrix’: event 12
           |
           |
         ‘newGL4DUMatrix’: events 13-14
           |
           |  916 |   return m;
           |      |          ^
           |      |          |
           |      |          (13) ...to here
           |      |          (14) ‘<unknown>leaks here; was allocated at (10)
           |
@fiplox
Copy link
Contributor

fiplox commented Feb 6, 2021

C'est un peu bizarre, car d’après -fanalyzerl'allocation a eu lieu sur la ligne 911

@darnuria
Copy link
Collaborator Author

darnuria commented Feb 6, 2021

@fiplox probablement le code a bouger faut reposter une nouvelle version du warning.

@fiplox
Copy link
Contributor

fiplox commented Feb 6, 2021

@darnuria Je viens de recompiler avec -fanalyzer il dit toujours la même chose

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

2 participants