Fixed CID 1290 and 1291: the temp BString is initialized with a new BString and then immediately replaced. A later null check ensures it is OK to initialize it to NULL.
Also fixed a GCC warning about comparison between signed and unsigned. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27434 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3d65935d2d
commit
4239ee5d66
|
@ -165,14 +165,14 @@ status_t
|
|||
BJoystick::GetDeviceName(int32 n, char *name, size_t bufSize)
|
||||
{
|
||||
CALLED();
|
||||
BString *temp = new BString();
|
||||
BString *temp = NULL;
|
||||
if (fDevices != NULL && fDevices->CountItems() > n)
|
||||
temp = static_cast<BString*>(fDevices->ItemAt(n));
|
||||
else
|
||||
return B_BAD_INDEX;
|
||||
|
||||
if (temp != NULL && name != NULL) {
|
||||
if(temp->Length() > bufSize)
|
||||
if(temp->Length() > (int32)bufSize)
|
||||
return B_NAME_TOO_LONG;
|
||||
strncpy(name, temp->String(), bufSize);
|
||||
name[bufSize - 1] = '\0';
|
||||
|
|
Loading…
Reference in New Issue