Throw ParserError_InvalidKeymapCount if keymapCount == 0.
This commit is contained in:
@@ -28,38 +28,46 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
uint16_t keymapCount;
|
uint16_t keymapCount;
|
||||||
|
|
||||||
(void)dataModelVersion;
|
(void)dataModelVersion;
|
||||||
|
|
||||||
if (moduleConfigurationCount > 255) {
|
if (moduleConfigurationCount > 255) {
|
||||||
return ParserError_InvalidModuleConfigurationCount;
|
return ParserError_InvalidModuleConfigurationCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t moduleConfigurationIdx = 0; moduleConfigurationIdx < moduleConfigurationCount; moduleConfigurationIdx++) {
|
for (uint8_t moduleConfigurationIdx = 0; moduleConfigurationIdx < moduleConfigurationCount; moduleConfigurationIdx++) {
|
||||||
errorCode = parseModuleConfiguration(buffer);
|
errorCode = parseModuleConfiguration(buffer);
|
||||||
if (errorCode != ParserError_Success) {
|
if (errorCode != ParserError_Success) {
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macroCount = readCompactLength(buffer);
|
macroCount = readCompactLength(buffer);
|
||||||
if (macroCount > MAX_MACRO_NUM) {
|
if (macroCount > MAX_MACRO_NUM) {
|
||||||
return ParserError_InvalidMacroCount;
|
return ParserError_InvalidMacroCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t macroIdx = 0; macroIdx < macroCount; macroIdx++) {
|
for (uint8_t macroIdx = 0; macroIdx < macroCount; macroIdx++) {
|
||||||
errorCode = ParseMacro(buffer, macroIdx);
|
errorCode = ParseMacro(buffer, macroIdx);
|
||||||
if (errorCode != ParserError_Success) {
|
if (errorCode != ParserError_Success) {
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keymapCount = readCompactLength(buffer);
|
keymapCount = readCompactLength(buffer);
|
||||||
if (keymapCount > MAX_KEYMAP_NUM) {
|
if (keymapCount == 0 || keymapCount > MAX_KEYMAP_NUM) {
|
||||||
return ParserError_InvalidKeymapCount;
|
return ParserError_InvalidKeymapCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t keymapIdx = 0; keymapIdx < keymapCount; keymapIdx++) {
|
for (uint8_t keymapIdx = 0; keymapIdx < keymapCount; keymapIdx++) {
|
||||||
errorCode = ParseKeymap(buffer, keymapIdx, keymapCount, macroCount);
|
errorCode = ParseKeymap(buffer, keymapIdx, keymapCount, macroCount);
|
||||||
if (errorCode != ParserError_Success) {
|
if (errorCode != ParserError_Success) {
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ParserRunDry) {
|
if (!ParserRunDry) {
|
||||||
AllKeymapsCount = keymapCount;
|
AllKeymapsCount = keymapCount;
|
||||||
AllMacrosCount = macroCount;
|
AllMacrosCount = macroCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user