1
0
Fork 0

Allow zero-sized string for utf16/utf8 format type

This commit is contained in:
Duncan Ogilvie 2023-11-06 18:15:42 +01:00
parent 7f9dc7fc04
commit 49f9487a59
1 changed files with 2 additions and 7 deletions

View File

@ -61,19 +61,14 @@ static FORMATRESULT memoryFormatter(char* dest, size_t destCount, int argc, char
strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Invalid argument..."))); strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Invalid argument...")));
return FORMAT_ERROR_MESSAGE; return FORMAT_ERROR_MESSAGE;
} }
if(size == 0)
{
strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Not enough arguments...")));
return FORMAT_ERROR_MESSAGE;
}
if(size > 1024 * 1024 * 10) //10MB max if(size > 1024 * 1024 * 10) //10MB max
{ {
strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Too much data (10MB max)..."))); strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Too much data (10MB max)...")));
return FORMAT_ERROR_MESSAGE; return FORMAT_ERROR_MESSAGE;
} }
std::vector<Char> data(size); std::vector<Char> data(size);
duint read = 0; duint read = -1;
if(!MemRead(addr, data.data(), size * sizeof(Char), &read) && read == 0) if(!MemRead(addr, data.data(), size * sizeof(Char), &read) && read == -1)
{ {
strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Failed to read memory..."))); strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Failed to read memory...")));
return FORMAT_ERROR_MESSAGE; return FORMAT_ERROR_MESSAGE;