Skip to content

Commit c9d0811

Browse files
committed
Fix NULL handling in FQexecParams()
It turns out that if a column has a NOT NULL constraint, but the provided parameter for that column is NULL, if var->sqldata is allocated, the column will be filled with whatever the allocated memory contains (probably garbage, as we weren't initialising it). This does not happen if the column has no NOT NULL constraint.
1 parent 4f57c5c commit c9d0811

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Revision history for libfq
22

3+
0.4.3 2022-02-??
4+
- Fix NULL value handling in FQexecParams()
5+
36
0.4.2 2020-10-17
47
- Add configure option "--with-fbclient"
58
- Fix FQexplainStatement() output

src/libfq.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,11 +1541,9 @@ _FQexecParams(FBconn *conn,
15411541
_FQexecClearResult(result);
15421542
}
15431543

1544+
/* var->sqldata remains NULL to indicate NULL */
15441545
if (size >= 0)
1545-
{
1546-
var->sqldata = (char *)malloc(size);
15471546
var->sqllen = size;
1548-
}
15491547
}
15501548
else
15511549
{

0 commit comments

Comments
 (0)