cvs: php4 /ext/mssql php_mssql.c
| From: | Frank M. Kromann | Date: | Wed, 09 May 2001 19:18:05 +0000 |
| Subject: | cvs: php4 /ext/mssql php_mssql.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5631@lists.php.net to get a copy of this message | ||
fmk Wed May 9 12:18:05 2001 EDT
Modified files:
/php4/ext/mssql php_mssql.c
Log:
Minor change to the way string lengths are calculated and space alocated.
Index: php4/ext/mssql/php_mssql.c
diff -u php4/ext/mssql/php_mssql.c:1.45 php4/ext/mssql/php_mssql.c:1.46
--- php4/ext/mssql/php_mssql.c:1.45 Wed May 9 09:20:34 2001
+++ php4/ext/mssql/php_mssql.c Wed May 9 12:18:04 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mssql.c,v 1.45 2001/05/09 16:20:34 fmk Exp $ */
+/* $Id: php_mssql.c,v 1.46 2001/05/09 19:18:04 fmk Exp $ */
#ifdef COMPILE_DL_MSSQL
#define HAVE_MSSQL 1
@@ -742,7 +742,7 @@
unsigned char *res_buf;
int res_length = dbdatlen(mssql_ptr->link, offset);
- res_buf = (unsigned char *) emalloc(res_length);
+ res_buf = (unsigned char *) emalloc(res_length + 1);
bin = ((DBBINARY *)dbdata(mssql_ptr->link, offset));
memcpy(res_buf,bin,res_length);
res_buf[res_length] = '\0';
@@ -755,11 +755,11 @@
default: {
if (dbwillconvert(column_type,SQLCHAR)) {
char *res_buf;
- int res_length = dbdatlen(mssql_ptr->link,offset) + 1;
+ int res_length = dbdatlen(mssql_ptr->link,offset);
if (column_type == SQLDATETIM4) res_length += 14;
if (column_type == SQLDATETIME) res_length += 10;
- res_buf = (char *) emalloc(res_length);
+ res_buf = (char *) emalloc(res_length + 1);
res_length = dbconvert(NULL,column_type,dbdata(mssql_ptr->link,offset),
res_length,SQLCHAR,res_buf,-1);
result->value.str.val = res_buf;
@@ -787,7 +787,7 @@
unsigned char *res_buf;
int res_length = dbdatlen(mssql_ptr->link, offset);
- res_buf = (unsigned char *) emalloc(res_length);
+ res_buf = (unsigned char *) emalloc(res_length + 1);
bin = ((DBBINARY *)dbdata(mssql_ptr->link, offset));
memcpy(res_buf, bin, res_length);
res_buf[res_length] = '\0';
@@ -797,11 +797,11 @@
}
else if (dbwillconvert(coltype(offset),SQLCHAR)) {
unsigned char *res_buf;
- int res_length = dbdatlen(mssql_ptr->link,offset) + 1;
+ int res_length = dbdatlen(mssql_ptr->link,offset);
if (column_type == SQLDATETIM4) res_length += 14;
if (column_type == SQLDATETIME) res_length += 10;
- res_buf = (unsigned char *) emalloc(res_length);
+ res_buf = (unsigned char *) emalloc(res_length + 1);
res_length = dbconvert(NULL,coltype(offset),dbdata(mssql_ptr->link,offset), res_length,
SQLCHAR,res_buf,-1);
result->value.str.val = res_buf;