|
@@ -496,7 +496,7 @@ ini_t* ini_create( void* memctx )
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-ini_t* ini_load( char const* data, void* memctx )
|
|
|
|
|
|
|
+ini_t* ini_load( char const* data, unsigned int len, void* memctx )
|
|
|
{
|
|
{
|
|
|
ini_t* ini;
|
|
ini_t* ini;
|
|
|
char const* ptr;
|
|
char const* ptr;
|
|
@@ -504,17 +504,19 @@ ini_t* ini_load( char const* data, void* memctx )
|
|
|
char const* start;
|
|
char const* start;
|
|
|
char const* start2;
|
|
char const* start2;
|
|
|
int l;
|
|
int l;
|
|
|
|
|
+ char const* end;
|
|
|
|
|
|
|
|
ini = ini_create( memctx );
|
|
ini = ini_create( memctx );
|
|
|
|
|
|
|
|
ptr = data;
|
|
ptr = data;
|
|
|
|
|
+ end = ptr + len;
|
|
|
if( ptr )
|
|
if( ptr )
|
|
|
{
|
|
{
|
|
|
s = 0;
|
|
s = 0;
|
|
|
- while( *ptr )
|
|
|
|
|
|
|
+ while( ptr < end && *ptr )
|
|
|
{
|
|
{
|
|
|
/* trim leading whitespace */
|
|
/* trim leading whitespace */
|
|
|
- while( *ptr && *ptr <=' ' )
|
|
|
|
|
|
|
+ while( ptr < end && *ptr && *ptr <=' ' )
|
|
|
++ptr;
|
|
++ptr;
|
|
|
|
|
|
|
|
/* done? */
|
|
/* done? */
|
|
@@ -544,17 +546,17 @@ ini_t* ini_load( char const* data, void* memctx )
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
start = ptr;
|
|
start = ptr;
|
|
|
- while( *ptr && *ptr !='=' && *ptr != '\n' )
|
|
|
|
|
|
|
+ while( ptr < end && *ptr && *ptr !='=' && *ptr != '\n' )
|
|
|
++ptr;
|
|
++ptr;
|
|
|
|
|
|
|
|
if( *ptr == '=' )
|
|
if( *ptr == '=' )
|
|
|
{
|
|
{
|
|
|
l = (int)( ptr - start);
|
|
l = (int)( ptr - start);
|
|
|
++ptr;
|
|
++ptr;
|
|
|
- while( *ptr && *ptr <= ' ' && *ptr != '\n' )
|
|
|
|
|
|
|
+ while( ptr < end && *ptr && *ptr <= ' ' && *ptr != '\n' )
|
|
|
ptr++;
|
|
ptr++;
|
|
|
start2 = ptr;
|
|
start2 = ptr;
|
|
|
- while( *ptr && *ptr != '\n' )
|
|
|
|
|
|
|
+ while( ptr < end && *ptr && *ptr != '\n' )
|
|
|
++ptr;
|
|
++ptr;
|
|
|
while( *(--ptr) <= ' ' )
|
|
while( *(--ptr) <= ' ' )
|
|
|
(void)ptr;
|
|
(void)ptr;
|