Library: Added buffer-size attribute for <alloc>

This commit is contained in:
Daniel Marjamäki 2019-03-17 10:55:15 +01:00
parent a3257349b9
commit 18668a52b9
4 changed files with 18 additions and 1 deletions

View File

@ -32,6 +32,9 @@
<optional> <optional>
<attribute name="arg"><ref name="ARGNO"/></attribute> <attribute name="arg"><ref name="ARGNO"/></attribute>
</optional> </optional>
<optional>
<attribute name="buffer-size"><ref name="DATA-BUFFER-SIZE"/></attribute>
</optional>
<ref name="DATA-NAME"/> <ref name="DATA-NAME"/>
</element> </element>
<element name="use"><ref name="DATA-EXTNAME"/></element> <element name="use"><ref name="DATA-EXTNAME"/></element>
@ -458,6 +461,12 @@
</data> </data>
</define> </define>
<define name="DATA-BUFFER-SIZE">
<data type="string">
<param name="pattern">arg-value:[1-3]</param>
</data>
</define>
<define name="CONTAINER-ACTION"> <define name="CONTAINER-ACTION">
<choice> <choice>
<value>resize</value> <value>resize</value>

View File

@ -7320,7 +7320,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="2"/> <arg nr="2"/>
</function> </function>
<memory> <memory>
<alloc init="false">malloc</alloc> <alloc init="false" buffer-size="arg-value:1">malloc</alloc>
<alloc init="true">calloc</alloc> <alloc init="true">calloc</alloc>
<alloc init="false">aligned_alloc</alloc> <alloc init="false">aligned_alloc</alloc>
<alloc init="false">valloc</alloc> <alloc init="false">valloc</alloc>

View File

@ -200,6 +200,13 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
temp.arg = atoi(arg); temp.arg = atoi(arg);
else else
temp.arg = -1; temp.arg = -1;
const char *bufferSize = memorynode->Attribute("buffer-size");
if (bufferSize && std::strncmp(bufferSize, "arg-value:", 10) == 0)
temp.bufferSizeArgValue = bufferSize[10] - '0';
else
temp.bufferSizeArgValue = -1;
mAlloc[memorynode->GetText()] = temp; mAlloc[memorynode->GetText()] = temp;
} else if (memorynodename == "dealloc") { } else if (memorynodename == "dealloc") {
AllocFunc temp; AllocFunc temp;

View File

@ -73,6 +73,7 @@ public:
struct AllocFunc { struct AllocFunc {
int groupId; int groupId;
int arg; int arg;
int bufferSizeArgValue;
}; };
/** get allocation info for function */ /** get allocation info for function */