Skip to content

Commit

Permalink
Fix memleak pointed by issue #2439.
Browse files Browse the repository at this point in the history
Also change bzero to memset. bzero doesn't work on windows
  • Loading branch information
nerzhul committed Mar 8, 2015
1 parent 57d86cf commit 3ae16f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client.cpp
Expand Up @@ -401,8 +401,8 @@ void Client::step(float dtime)

char pName[PLAYERNAME_SIZE];
char pPassword[PASSWORD_SIZE];
bzero(pName, PLAYERNAME_SIZE);
bzero(pPassword, PLAYERNAME_SIZE);
memset(pName, 0, PLAYERNAME_SIZE * sizeof(char));
memset(pPassword, 0, PASSWORD_SIZE * sizeof(char));

snprintf(pName, PLAYERNAME_SIZE, "%s", myplayer->getName());
snprintf(pPassword, PASSWORD_SIZE, "%s", m_password.c_str());
Expand Down

4 comments on commit 3ae16f1

@est31
Copy link
Contributor

@est31 est31 commented on 3ae16f1 Mar 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialised value != memleak

@nerzhul
Copy link
Member Author

@nerzhul nerzhul commented on 3ae16f1 Mar 9, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zeno-
Copy link
Contributor

@Zeno- Zeno- commented on 3ae16f1 Mar 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did the bzero come from?

Edit: nevermind. I was the previous commit :)

@nerzhul
Copy link
Member Author

@nerzhul nerzhul commented on 3ae16f1 Mar 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i fixed it like we do on BSD's but with this commit i make the code portable for Windows :) (and also fix a variable name)

Please sign in to comment.