# [FIX] Bug #25585: PHP crash if executed MSSQL-query with RAISERROR() call and error 515

- Thread: https://externals.io/message/5961
- Original archive: https://news-web.php.net/php.internals/5961
- Started by Frank M. Kromann on 2003-12-01T23:06:39+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #5961 — Frank M. Kromann — 2003-12-01T23:06:39+00:00

URL: https://externals.io/message/5961#5961

Hi Michael,

I'm running on Windows XP and using MSSQL server 7.0 and 2000 both with
the latest service packs.

PHP 4.3.5-dev (cli) (built: Nov  4 2003 16:23:54)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

ntwdblib is 2000.2.8.0

- Frank

> Frank,
> 
> Hummm... I am seeing the crash on my development machine.  Using PHP
> 4.3.4 recompiled with the most recent php_mssql.c (1.86.2.26) this code
> fails for me exactly as descibed in the bug report when run with the
> CLI under Windows 2000 Professional.  I'm running SQL Server 2000 SP3
> with version 8.00.194 of ntwdblib.dll.  What is your configuration?
> 
> Michael
> 
> --- "Frank M. Kromann" <frank@kromann.info> wrote:
> > […]
> 
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/

---

## #5976 — Michael Sisolak — 2003-12-02T01:35:51+00:00

URL: https://externals.io/message/5961#5976 · In reply to: #5961

--- "Frank M. Kromann" <frank@kromann.info> wrote:

> I'm running on Windows XP and using MSSQL server 7.0 and 2000 both
> with the latest service packs.
> 
> PHP 4.3.5-dev (cli) (built: Nov  4 2003 16:23:54)
> Copyright (c) 1997-2003 The PHP Group
> Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
> 
> ntwdblib is 2000.2.8.0
> 

Frank,

I've found the reason for the crash in the bug report, although I can't
explain why we are getting such different outcomes.  The current
PHP_RSHUTDOWN_FUNCTION(mssql) is:

PHP_RSHUTDOWN_FUNCTION(mssql)
{
	STR_FREE(MS_SQL_G(appname));
	if (MS_SQL_G(server_message)) {
		STR_FREE(MS_SQL_G(server_message));
	}
	return SUCCESS;
}

The string is free'd, but the MS_SQL_G(server_message) isn't properly
reset to empty_string.  If I change this to:

PHP_RSHUTDOWN_FUNCTION(mssql)
{
	STR_FREE(MS_SQL_G(appname));
	if (MS_SQL_G(server_message)) {
		STR_FREE(MS_SQL_G(server_message));
		MS_SQL_G(server_message) = empty_string;
	}
	return SUCCESS;
}

then the crash goes away.  (For consistancy sake the
"MS_SQL_G(server_message) = NULL;" on line 1315 should probably be
changed to "= empty_string" also.)

When I run the query in the bug report the call to mssql_query only
processes the first chunk of statements of the multi-statement query
and it holds on to the output of the rest of them.  They remainder
don't actually end up getting processed until during the call to
dbclose() in _close_mssql_link.  The output I end up seeing is:

Warning: mssql_query(): message: Cannot insert the value `NULL` into
column 'myFie
ld1', table 'myDB.dbo.myTable'; column does not allow nulls. INSERT
fails. (seve
rity 16) in c:\temp\test.php on line 30
Result is true
DB Error is The statement has been terminated.

Warning: Unknown(): message: Some error (severity 18) in Unknown on
line 0

Note that the "Some error" message comes after all the other output
lines and has no script location tied to it.  I'm going to continue to
dig into this.  Please let me know if you have any thoughts about where
I might look.

Michael

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
