@@ -19,7 +19,7 @@ void Log(const char* format, ...)
1919 va_start (args , format );
2020 va_list args2 ;
2121 va_copy (args2 , args );
22- int size = vsnprintf (NULL , 0 , format , args );
22+ int size = vsnprintf (NULL , 0 , format , args ) + 1 ;
2323 char * buffer = malloc ((unsigned long ) size );
2424 vsnprintf (buffer , (unsigned long ) size , format , args2 );
2525 printf ("%s\n" , buffer );
@@ -38,11 +38,11 @@ LIPCcode stub(LIPC *lipc, const char *property, void *value, void*) {
3838 (char * )value );
3939 char * mutValue = strdup (value );
4040 char * id = strtok ((char * )mutValue , ":" );
41- int bufSize = snprintf (NULL , 0 , "%s:0:" , id );
42- char * response = (char * ) malloc ((unsigned long ) bufSize );
41+ int bufSize = snprintf (NULL , 0 , "%s:0:" , id ) + 1 ;
42+ char * response = (char * ) malloc ((unsigned long ) bufSize + 1 );
4343 snprintf (response , (unsigned long ) bufSize , "%s:0:" , id );
4444 Log ("Replying with %s" , response );
45- bufSize = snprintf (NULL , 0 , "%sresult" , property );
45+ bufSize = snprintf (NULL , 0 , "%sresult" , property ) + 1 ;
4646 char * target = (char * ) malloc ((unsigned long ) bufSize );
4747 snprintf (target , (unsigned long ) bufSize , "%sresult" , property );
4848 Log ("Replying with %s, %s" , target , response );
0 commit comments