none
State Error_C4703_potentially uninitialized local pointer variable 'mmFiles' used_FilesystemFilter RRS feed

  • Question

  • if (Irp->MdlAddress != 0) {
    		if (Irp->MdlAddress->MdlFlags == 5) {
    			//maps the physical pages that are described by The MDL to a virtual address
    			mmFiles = MmMapLockedPagesSpecifyCache(Irp->MdlAddress, 0, MmCached, 0, 0, 0x10);
    			if (mmFiles == 0) {
    				FreeMdl(Irp, LclContext);
    				return 0;
    			};
    		}
    		else if (Irp->MdlAddress->MappedSystemVa == 0) {
    			FreeMdl(Irp, LclContext);
    			return 0;
    		};
    	}
    	else {
    		mmFiles = Irp->UserBuffer;
    	};
    	if (FileCheck(mmFiles, Irp->Tail.Overlay.CurrentStackLocation->Parameters.QueryDirectory.Length, \
    		EndOfFile, FilenameOffset, FilenameLength) != 0) {
    		Irp->IoStatus.Status = STATUS_SUCCESS;
    		FreeMdl(Irp, Context);
    		return 0;
    	};
    	if (Irp->MdlAddress == 0) {
    		LclContext = ExAllocatePool(0, 4);
    		if (LclContext == 0 || AllocateMdl(LclContext, Irp, Irp->Tail.Overlay.CurrentStackLocation) == 0) {
    			FreeMdl(Irp, LclContext);
    			Irp->IoStatus.Status = 0x0C000009A;
    			return 0;
    		};
    	};


    Error C4703 potentially uninitialized local pointer variable 'mmFiles' used FilesystemFilter c:\users\king\source\repos\filesystemfilter\filesystemfilter\main.c 502

    Friday, August 31, 2018 4:59 AM

Answers

  • You didn't ask a question, but I assume you're asking why it thinks "mmfiles" is potentially uninitialized.

    Watch what happens.  Assume MdlFlags is not 5, and MappedSystemVa is not 0.  In that case, mmFiles certainly will be uninitialized when you pass it to FileCheck.

    It's trivially easy to initialize mmfiles to something, but perhaps you need to think about what mmfiles should be when MdlFlags is not 5.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Friday, August 31, 2018 6:49 AM

All replies

  • You didn't ask a question, but I assume you're asking why it thinks "mmfiles" is potentially uninitialized.

    Watch what happens.  Assume MdlFlags is not 5, and MappedSystemVa is not 0.  In that case, mmFiles certainly will be uninitialized when you pass it to FileCheck.

    It's trivially easy to initialize mmfiles to something, but perhaps you need to think about what mmfiles should be when MdlFlags is not 5.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Friday, August 31, 2018 6:49 AM
  • Tell me how do i solve the problem i have included code snippet.

    How do i successfully build the driver.

    Friday, August 31, 2018 8:05 AM