a 0 length printer data value is not a memory allocation error; fix CR601
authorGerald Carter <jerry@samba.org>
Thu, 9 Jan 2003 19:51:28 +0000 (19:51 +0000)
committerGerald Carter <jerry@samba.org>
Thu, 9 Jan 2003 19:51:28 +0000 (19:51 +0000)
(This used to be commit 3442c270f1bc67890f4e2de3386fcfdec610170d)

source3/rpc_server/srv_spoolss_nt.c

index 291ed50ddd99789c17cb27968ba7cbe149233102..279bbb86ffce22c23cf0715ee62cdd58b7a7308f 100644 (file)
@@ -2104,8 +2104,16 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe
        
        if ( in_size ) {
                data_len = (size > in_size) ? in_size : size*sizeof(uint8);
-               if ( (*data  = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL )
-                       return WERR_NOMEM;
+               
+               /* special case for 0 length values */
+               if ( data_len ) {
+                       if ( (*data  = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL )
+                               return WERR_NOMEM;
+               }
+               else {
+                       if ( (*data  = (uint8 *)talloc_zero(ctx, in_size)) == NULL )
+                               return WERR_NOMEM;
+               }
        }
        else
                *data = NULL;