]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Call finish_select_query if we experience an error retrieving the result
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 12 Jan 2017 15:10:22 +0000 (15:10 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 12 Jan 2017 15:10:34 +0000 (15:10 +0000)
src/modules/rlm_sql/rlm_sql.c

index 6813e0b5bcaed0c9517b332ef0d2a196bc1083bc..a019b738941b714620b200e53c803906f7713f68 100644 (file)
@@ -181,6 +181,7 @@ static ssize_t sql_xlat(UNUSED TALLOC_CTX *ctx, char **out, UNUSED size_t outlen
                numaffected = (inst->driver->sql_affected_rows)(handle, inst->config);
                if (numaffected < 1) {
                        RDEBUG("SQL query affected no rows");
+                       (inst->driver->sql_finish_query)(handle, inst->config);
 
                        goto finish;
                }
@@ -197,7 +198,10 @@ static ssize_t sql_xlat(UNUSED TALLOC_CTX *ctx, char **out, UNUSED size_t outlen
        if (rcode != RLM_SQL_OK) goto query_error;
 
        rcode = rlm_sql_fetch_row(&row, inst, request, &handle);
-       if (rcode) goto query_error;
+       if (rcode) {
+               (inst->driver->sql_finish_select_query)(handle, inst->config);
+               goto query_error;
+       }
 
        if (!row) {
                RDEBUG("SQL query returned no results");