程序被视为病毒

I'm trying to understand how to work with realloc on Windows.

So I read this page, copied the code into VSCode and modified it a little bit. Now I have the following code:

#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

int main( void )
{
   long * buffer;
   long * tmp;
   size_t size;

   buffer = malloc(1000 * sizeof(long));

    // ERROR
    if(buffer == NULL)
      exit(1);
    // ERROR

   tmp = realloc(buffer, size + (1000 * sizeof(long)));

   if(tmp == NULL) {
       free(buffer);
        exit( 1 );
   }

   free(tmp);
   exit(0);
}

But if I compile it with gcc, Windows Defender says that it's a virus and deletes its execution file. Now I'm interested in why Windows Defender thinks that this is a virus. Do you have an idea what the reason might be?

评论