From 199bb5f33a877481a1f9cb5b9f2eaa7f411cd2d7 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 10 Apr 2010 12:21:19 +0200 Subject: [PATCH] Revert "Use bstrdup and use a goto for one exit from function." This reverts commit 172a2f4c66c651bb29610cce72d15061e7c94509. --- bacula/src/cats/myingres.sc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/bacula/src/cats/myingres.sc b/bacula/src/cats/myingres.sc index e632d36999..1289f13eed 100644 --- a/bacula/src/cats/myingres.sc +++ b/bacula/src/cats/myingres.sc @@ -31,23 +31,24 @@ short INGgetCols(const char *query) memset(sqlda, 0, (IISQDA_HEAD_SIZE + (number * IISQDA_VAR_SIZE))); sqlda->sqln = number; - - stmt = bstrdup(query); + + stmt = (char*)malloc(strlen(stmt)+1); + bstrncpy(stmt,stmt,strlen(stmt)+1); EXEC SQL PREPARE s1 from :stmt; if (INGcheck() < 0) { - number = -1; - goto bail_out; + free(stmt); + free(sqlda); + return -1; } EXEC SQL DESCRIBE s1 into :sqlda; if (INGcheck() < 0) { - number = -1; - goto bail_out; + free(stmt); + free(sqlda); + return -1; } number = sqlda->sqld; - -bail_out: free(stmt); free(sqlda); return number; @@ -67,7 +68,8 @@ static inline IISQLDA *INGgetDescriptor(short numCols, const char *query) sqlda->sqln = numCols; - stmt = bstrdup(query); + stmt = (char *)malloc(strlen(stmt)+1); + bstrncpy(stmt,stmt,strlen(stmt)+1); EXEC SQL PREPARE s2 INTO :sqlda FROM :stmt; @@ -445,7 +447,8 @@ int INGexec(INGconn *conn, const char *query) char *stmt; EXEC SQL END DECLARE SECTION; - stmt = bstrdup(query); + stmt = (char *)malloc(strlen(query)+1); + bstrncpy(stmt,query,strlen(query)+1); rowcount = -1; EXEC SQL EXECUTE IMMEDIATE :stmt; @@ -567,7 +570,7 @@ char *INGerrorMessage(const INGconn *conn) EXEC SQL END DECLARE SECTION; EXEC SQL INQUIRE_INGRES(:errbuf = ERRORTEXT); - memcpy(conn->msg, &errbuf, 256); + memcpy(conn->msg,&errbuf,256); return conn->msg; } -- 2.39.5