📚 Practice Mode

Secure Coding and Vulnerabilities Quiz

Learn at your own pace with hints and detailed explanations

1 / 20
Multiple Choice
int main(int argc,char* argv[]) {
    int *ptr1=new int;
    if(ptr1==NULL)    exit(1);
    int *ptr2=new int;
    if(ptr2==NULL)    exit(1);
    char* j;
    j=argv[1];
    int k=atoi(j);
    if (j==0){
        Ptr1=&k;
        delete ptr2;  /*1*/
    }
    else {
        Ptr2=&k;
    }
    delete ptr1;  /*2*/  
    delete ptr2; /*3*/   
    return 0;
}

which line of the code should be deleted to remove vulnerability

  1. line 1 and line 3
  2. line 2 and line 3
  3. line 1
  4. line 3