From b67da6965f582c9327bf58036c7cb637d61aeec3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 30 Jun 2004 03:14:39 +0000 Subject: [PATCH] Fixed field lookup bug. Fixed bug in CString. --- dlls/pgsql/CString.h | 5 ++++- dlls/pgsql/pgsql.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dlls/pgsql/CString.h b/dlls/pgsql/CString.h index 137be93f..c5e315bc 100755 --- a/dlls/pgsql/CString.h +++ b/dlls/pgsql/CString.h @@ -32,7 +32,8 @@ public: return; } Grow(strlen(d)); - strcpy(v, d); + if (v) + strcpy(v, d); } void clear() @@ -70,6 +71,8 @@ public: private: void Grow(int d) { + if (d<1) + return; if (d > mSize) { char *t = new char[d+1]; diff --git a/dlls/pgsql/pgsql.cpp b/dlls/pgsql/pgsql.cpp index 4f41dce9..28ac140d 100755 --- a/dlls/pgsql/pgsql.cpp +++ b/dlls/pgsql/pgsql.cpp @@ -215,7 +215,7 @@ static cell AMX_NATIVE_CALL sql_getfield(AMX *amx, cell *params) // 2-4 params SQLResult *Result = Results[id]; int numParams = (*params)/sizeof(cell); cell *fAddr = NULL; - const char *field = Result->GetField(id); + const char *field = Result->GetField(params[2]-1); if (field == NULL) { MF_RaiseAmxError(amx, AMX_ERR_NATIVE); @@ -262,7 +262,7 @@ static cell AMX_NATIVE_CALL sql_getresult(AMX *amx, cell *params) // 4 params cell *fAddr = NULL; int len = 0; const char *column = MF_GetAmxString(amx, params[2], 0, &len); - const char *field = Result->GetField(id); + const char *field = Result->GetField(column); if (field == NULL) { MF_RaiseAmxError(amx, AMX_ERR_NATIVE);