Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Minor sanity checking and tweaks in SDL_JoystickGetGUIDString().
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Dec 11, 2012
1 parent 812f5f9 commit e1de070
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/joystick/SDL_joystick.c
Expand Up @@ -698,22 +698,22 @@ SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
void SDL_JoystickGetGUIDString( SDL_JoystickGUID guid, char *pszGUID, int cbGUID )
{
static const char k_rgchHexToASCII[] = "0123456789abcdef";
char *pchOut = NULL;
char *pchString = NULL;
int i;

pchOut = pszGUID;

for ( i = 0; i < sizeof(guid) && i < (cbGUID-1); i++ )
if ((pszGUID == NULL) || (cbGUID <= 0)) {
return;
}

for ( i = 0; i < sizeof(guid.data) && i < (cbGUID-1); i++ )
{
// each input byte writes 2 ascii chars, and might write a null byte.
// If we don't have room for next input byte, stop
unsigned char c = guid.data[i];

*pchOut++ = k_rgchHexToASCII[ c >> 4 ];
*pchOut++ = k_rgchHexToASCII[ c & 0x0F ];
*pszGUID++ = k_rgchHexToASCII[ c >> 4 ];
*pszGUID++ = k_rgchHexToASCII[ c & 0x0F ];
}
*pchOut = '\0';
*pszGUID = '\0';
}


Expand Down

0 comments on commit e1de070

Please sign in to comment.