* StringFromStream() did not work correctly for empty strings (messed up the stream
position). * StringFromStream() called BString::LockBuffer() with "length", but touched "length + 1" bytes. * Prepared for the new "display as" FileTypes feature. * The "DefaultQueryTemplate" folder now adds the MIME type of the folder to the attribute menu for simplified editing (before, you had to move a file with a matching file type into that folder to be able to add the attributes you likely wanted to see). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21509 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -127,14 +127,14 @@ AttrHashString(const char *string, uint32 type)
|
||||
bool
|
||||
ValidateStream(BMallocIO *stream, uint32 key, int32 version)
|
||||
{
|
||||
uint32 test_key;
|
||||
int32 test_version;
|
||||
uint32 testKey;
|
||||
int32 testVersion;
|
||||
|
||||
if (stream->Read(&test_key, sizeof(uint32)) <= 0
|
||||
|| stream->Read(&test_version, sizeof(int32)) <=0)
|
||||
if (stream->Read(&testKey, sizeof(uint32)) <= 0
|
||||
|| stream->Read(&testVersion, sizeof(int32)) <=0)
|
||||
return false;
|
||||
|
||||
return test_key == key && test_version == version;
|
||||
return testKey == key && testVersion == version;
|
||||
}
|
||||
|
||||
|
||||
@@ -1075,14 +1075,13 @@ StringFromStream(BString *string, BMallocIO *stream, bool endianSwap)
|
||||
if (endianSwap)
|
||||
length = SwapInt32(length);
|
||||
|
||||
if (length <= 0 || length > 10000) {
|
||||
// ToDo:
|
||||
// should fail here
|
||||
if (length < 0 || length > 10000) {
|
||||
// TODO: should fail here
|
||||
PRINT(("problems instatiating a string, length probably wrong %d\n", length));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
char *buffer = string->LockBuffer(length);
|
||||
char *buffer = string->LockBuffer(length + 1);
|
||||
stream->Read(buffer, (size_t)length + 1);
|
||||
string->UnlockBuffer(length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user