r19824: Fix the max value calculation in QueryInfoKey
authorVolker Lendecke <vlendec@samba.org>
Tue, 21 Nov 2006 19:47:48 +0000 (19:47 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:16:00 +0000 (12:16 -0500)
(This used to be commit cd14b7f05234f540601cd2c5841a52dd047c965d)

source3/rpc_server/srv_winreg_nt.c

index c45be0845487864bd3a086093940d9216de0ccf0..23b594ac78f105bb5717c01ad73e551acedf9a28 100644 (file)
@@ -163,7 +163,6 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum,
                                     uint32 *maxlen, uint32 *maxsize )
 {
        REGVAL_CTR      *values;
-       REGISTRY_VALUE  *val;
        uint32          sizemax, lenmax;
        int             i, num_values;
        
@@ -178,15 +177,17 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum,
        
        lenmax = sizemax = 0;
        num_values = regval_ctr_numvals( values );
-       
-       val = regval_ctr_specific_value( values, 0 );
-       
-       for ( i=0; i<num_values && val; i++ ) 
-       {
-               lenmax  = MAX(lenmax,  val->valuename ? strlen(val->valuename)+1 : 0 );
+
+       for ( i=0; i<num_values; i++ ) {
+               REGISTRY_VALUE *val;
+
+               if (!(val = regval_ctr_specific_value( values, i ))) {
+                       break;
+               }
+
+               lenmax  = MAX(lenmax, val->valuename ?
+                             strlen(val->valuename)+1 : 0 );
                sizemax = MAX(sizemax, val->size );
-               
-               val = regval_ctr_specific_value( values, i );
        }
 
        *maxnum   = num_values;