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:
@@ -165,14 +165,14 @@ status_t
|
|||||||
BJoystick::GetDeviceName(int32 n, char *name, size_t bufSize)
|
BJoystick::GetDeviceName(int32 n, char *name, size_t bufSize)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BString *temp = new BString();
|
BString *temp = NULL;
|
||||||
if (fDevices != NULL && fDevices->CountItems() > n)
|
if (fDevices != NULL && fDevices->CountItems() > n)
|
||||||
temp = static_cast<BString*>(fDevices->ItemAt(n));
|
temp = static_cast<BString*>(fDevices->ItemAt(n));
|
||||||
else
|
else
|
||||||
return B_BAD_INDEX;
|
return B_BAD_INDEX;
|
||||||
|
|
||||||
if (temp != NULL && name != NULL) {
|
if (temp != NULL && name != NULL) {
|
||||||
if(temp->Length() > bufSize)
|
if(temp->Length() > (int32)bufSize)
|
||||||
return B_NAME_TOO_LONG;
|
return B_NAME_TOO_LONG;
|
||||||
strncpy(name, temp->String(), bufSize);
|
strncpy(name, temp->String(), bufSize);
|
||||||
name[bufSize - 1] = '\0';
|
name[bufSize - 1] = '\0';
|
||||||
|
|||||||
Reference in New Issue
Block a user