Invalid Null Pointer - Microsoft Visual C++ 2010 Express

Hello guys. I am a beginner here. Recently, I had run a project/solution in Microsoft Visual C++ 2010 Express.The build was successful.But when I try to debug the solution, an error pop up.It says..

"Debug Assertion Failed!
Program: ...
File: c:\program files\Microsoft visual studio 10.0\vc\include\istream
Line:990
Expression: invalid null pointer...."

Can anyone here help me cause I don't know where to fix the error.Is it something to do with line 990 in istream file? Here is the istream file from line 984 until 1024. I'm sorry I don't know to include which lines. I can't include the full istream file as it's too long.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
// EXTRACTORS
template<class _Elem,
	class _Traits> inline
	basic_istream<_Elem, _Traits>& operator>>(
		basic_istream<_Elem, _Traits> && _Istr, _Elem *_Str)
	{	// extract NTBS
	_DEBUG_POINTER(_Str);
	typedef basic_istream<_Elem, _Traits> _Myis;
	typedef ctype<_Elem> _Ctype;
	ios_base::iostate _State = ios_base::goodbit;
	_Elem *_Str0 = _Str;
	const typename _Myis::sentry _Ok(_Istr);

	if (_Ok)
		{	// state okay, extract characters
		const _Ctype& _Ctype_fac = _USE(_Istr.getloc(), _Ctype);

		_TRY_IO_BEGIN
		streamsize _Count = 0 < _Istr.width() ? _Istr.width() : INT_MAX;
		typename _Myis::int_type _Meta = _Istr.rdbuf()->sgetc();
		_Elem _Ch;
		for (; 0 < --_Count; _Meta = _Istr.rdbuf()->snextc())
			if (_Traits::eq_int_type(_Traits::eof(), _Meta))
				{	// end of file, quit
				_State |= ios_base::eofbit;
				break;
				}
			else if (_Ctype_fac.is(_Ctype::space,
				_Ch = _Traits::to_char_type(_Meta))
					|| _Ch == _Elem())
				break;	// whitespace or nul, quit
			else
				*_Str++ = _Traits::to_char_type(_Meta);	// add it to string
		_CATCH_IO_(_Istr)
		}

	*_Str = _Elem();	// add terminating null character
	_Istr.width(0);
	_Istr.setstate(_Str == _Str0 ? _State | ios_base::failbit : _State);
	return (_Istr);
	}
The error will be certainly not in the standard library. Debug your code.
This is the output when I debug the project.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'attestation1.exe': Loaded 'C:\Users\NORA\Documents\Visual Studio 2010\Projects\rosz\Node\attestation1\Debug\attestation1.exe', Symbols loaded.
'attestation1.exe': Loaded 'C:\Windows\System32\ntdll.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\kernel32.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'attestation1.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'attestation1.exe': Loaded 'C:\Windows\System32\user32.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\gdi32.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\lpk.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\usp10.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\imm32.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\msctf.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\advapi32.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\sechost.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\uxtheme.dll', Symbols loaded.
'attestation1.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\ole32.dll', Symbols loaded.
'attestation1.exe': Loaded 'C:\Windows\System32\cryptbase.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\clbcatq.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Symbols loaded (source information stripped).
'attestation1.exe': Loaded 'C:\Program Files\Internet Download Manager\idmmkb.dll', Cannot find or open the PDB file
The program '[4428] attestation1.exe: Native' has exited with code 3 (0x3).
This is the output when I debug the project.

Hiya, showing that isn't much use really.

Run your stuff in debug, when it crashes, break into it and look at the call stack.
https://msdn.microsoft.com/en-us/library/windows/hardware/hh439516%28v=vs.85%29.aspx

Make your way down the stack until you come to one of your function calls and click on this. This will then show you your line of code that is trying to use the null pointer.
Last edited on
I'm sorry. This is the output from the call stack. And I give you the code that has the error. The line in the code that I've bold is the one that pointed by the call stack. I hope you can help me.

> attestation1.exe!std::operator>><char,std::char_traits<char> >(std::basic_istream<char,std::char_traits<char> > && _Istr, char * _Str) Line 1020 + 0x3 bytes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
basic_istream<_Elem, _Traits> && _Istr, _Elem *_Str)
	{	// extract NTBS
	_DEBUG_POINTER(_Str);
	typedef basic_istream<_Elem, _Traits> _Myis;
	typedef ctype<_Elem> _Ctype;
	ios_base::iostate _State = ios_base::goodbit;
	_Elem *_Str0 = _Str;
	const typename _Myis::sentry _Ok(_Istr);

	if (_Ok)
		{	// state okay, extract characters
		const _Ctype& _Ctype_fac = _USE(_Istr.getloc(), _Ctype);

		_TRY_IO_BEGIN
		streamsize _Count = 0 < _Istr.width() ? _Istr.width() : INT_MAX;
		typename _Myis::int_type _Meta = _Istr.rdbuf()->sgetc();
		_Elem _Ch;
		for (; 0 < --_Count; _Meta = _Istr.rdbuf()->snextc())
			if (_Traits::eq_int_type(_Traits::eof(), _Meta))
				{	// end of file, quit
				_State |= ios_base::eofbit;
				break;
				}
			else if (_Ctype_fac.is(_Ctype::space,
				_Ch = _Traits::to_char_type(_Meta))
					|| _Ch == _Elem())
				break;	// whitespace or nul, quit
			else
				*_Str++ = _Traits::to_char_type(_Meta);	// add it to string
		_CATCH_IO_(_Istr)
		}

	*_Str = _Elem();	// add terminating null character
	_Istr.width(0);
	_Istr.setstate(_Str == _Str0 ? _State | ios_base::failbit : _State);
	return (_Istr);
	}


> attestation1.exe!std::operator>><char,std::char_traits<char> >(std::basic_istream<char,std::char_traits<char> > & _Istr, char * _Str) Line 1085 + 0x16 bytes

1
2
3
4
basic_istream<_Elem, _Traits>& _Istr, _Elem *_Str)
	{	// extract NTBS
	return (_STD move(_Istr) >> _Str);
	}


> attestation1.exe!operator>>(std::basic_istream<char,std::char_traits<char> > & s, Big & x) Line 276 + 0x13 bytes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
istream& operator>>(istream& s, Big& x)
{ 
  miracl *mip=get_mip();
  if (mip->IOBASE>60) 
  {
     s.sync(); 
     s.getline(mip->IOBUFF,mip->IOBSIZ);
  }
  else s >> mip->IOBUFF;
  if (s.eof() || s.bad()) 
  {   
      zero(x.fn); 
      return s; 
  }
  cinstr(x.fn,mip->IOBUFF); 
  return s;
}


> attestation1.exe!encrypt() Line 454 + 0x1a bytes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
int encrypt()
{
    miracl *mip=mirsys(16,0);   // thread-safe ready. (32,0) for 1024 bit p
    ifstream common("common.ibe");
    ifstream plaintext;
    ofstream key_file,ciphertext;
    ECn U,P,Ppub,Qid,infinity;
    ZZn2 gid,cube,w;
    char key[HASH_LEN],pad[HASH_LEN],rho[HASH_LEN],V[HASH_LEN],W[HASH_LEN];
    char ifname[100],ofname[100],ch,iv[16];
    Big p,q,r,x,y,cof;
    int i,bits;
    long seed;
    aes a;

    cout << "Enter your 9 digit number  = ";
    cin >> seed;
    irand(seed);

// ENCRYPT

    common >> bits;
    mip->IOBASE=16;
    common >> p >> q;

    cof=(p+1)/q;

    common >> x >> y;
    EBrick B(x,y,(Big)0,(Big)1,p,8,QBITS);   // precomputation based on fixed P, 8-bit window

#ifdef AFFINE
    ecurve(0,1,p,MR_AFFINE);
#endif
#ifdef PROJECTIVE
    ecurve(0,1,p,MR_PROJECTIVE);
#endif

    P.set(x,y);

    common >> x >> y;
    Ppub.set(x,y);

    common >> x >> y;
    cube.set(x,y);

    char id[1000];
    cout << "Enter your correspondents email address (lower case)" << endl;
    cin.get();
    cin.getline(id,1000);

    mip->IOBASE=10;
    Qid=map_to_point(id);

// This can be done before we know the message to encrypt

    if (!ecap(Ppub,Qid,q,cube,gid))      // ** swap argument order
    {                                    // Qid must be second
        cout << "Bad Parameters" << endl;
        exit(0);
    } 

//
// prepare to encrypt file with random session key
//

    for (i=0;i<HASH_LEN;i++) key[i]=(char)brand();
    for (i=0;i<16;i++) iv[i]=i; // set CFB IV

    aes_init(&a,MR_CFB1,16,key,iv);
    
// figure out where input is coming from

    cout << "Text file to be encoded = " ;
    cin >> ifname;

   /* set up input file */
    strcpy(ofname,ifname);
    strip(ofname);
    strcat(ofname,".ibe");
    plaintext.open(ifname,ios::in); 
    if (!plaintext)
    {
        cout << "Unable to open file " << ifname << "\n";
        return 0;
    }
    cout << "encoding message\n";
    ciphertext.open(ofname,ios::binary|ios::out);

// now encrypt the plaintext file

    forever
    { // encrypt input ..
        plaintext.get(ch);
        if (plaintext.eof()) break;
        aes_encrypt(&a,&ch);
        ciphertext << ch;
    }

    aes_end(&a);

//
// Now IBE encrypt the session key
//

    for (i=0;i<HASH_LEN;i++) rho[i]=(char)brand();
//cout << "rho= " << rho << endl;
//cout << "key= " << key << endl;
    r=H3(rho,key)%q;

    B.mul(r,x,y);       // U=r*P
    U.set(x,y);

    w=pow(gid,r);         

//cout << "r= " << r << endl;
//cout << "w= " << w << endl;
    
    H2(w,pad);
//cout << "pad1= " << pad << endl;    
    for (i=0;i<HASH_LEN;i++) 
    {
        V[i]=rho[i]^pad[i];
        pad[i]=0;
    }

//cout << "rho= " << rho << endl;

    H4(rho,rho);


    for (i=0;i<HASH_LEN;i++) 
    {
        W[i]=key[i]^rho[i];
        rho[i]=0;
    }

    strip(ofname);
    strcat(ofname,".key");
    mip->IOBASE=16;
    key_file.open(ofname);
    U.get(x,y);
    key_file << y << endl;
    x=from_binary(HASH_LEN,V);      // output bit strings in handy Big format
    key_file << x << endl;
    x=from_binary(HASH_LEN,W);
    key_file << x << endl;

	return 0;
}


> attestation1.exe!main(int argc, char * * argv) Line 889

1
2
3
4
5
6
7
8
9
int _tmain(int argc, _TCHAR* argv[])
{
	nonce_TV();
	encrypt();
	connection();

	return 0;

}

Last edited on
Topic archived. No new replies allowed.