Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 61a3886

Browse files
committed
Fix libpq compression when no compression algorithms are avaiable
1 parent 990be8e commit 61a3886

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/common/zpq_stream.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ zpq_write(ZpqStream *zs, void const *buf, size_t size, size_t* processed)
440440
void
441441
zpq_free(ZpqStream *zs)
442442
{
443-
zpq_algorithms[zpq_algorithm_impl].free(zs);
443+
if (zs)
444+
zpq_algorithms[zpq_algorithm_impl].free(zs);
444445
}
445446

446447
char const*
@@ -453,7 +454,7 @@ zpq_error(ZpqStream *zs)
453454
size_t
454455
zpq_buffered(ZpqStream *zs)
455456
{
456-
return zpq_algorithms[zpq_algorithm_impl].buffered(zs);
457+
return zs ? zpq_algorithms[zpq_algorithm_impl].buffered(zs) : 0;
457458
}
458459

459460
/*

src/interfaces/libpq/fe-connect.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,10 @@ pgthreadlock_t pg_g_threadlock = default_threadlock;
431431
void
432432
pqDropConnection(PGconn *conn, bool flushInput)
433433
{
434-
if (conn->zstream)
435-
{
436-
/* Release compression streams */
437-
zpq_free(conn->zstream);
438-
conn->zstream = NULL;
439-
}
434+
/* Release compression streams */
435+
zpq_free(conn->zstream);
436+
conn->zstream = NULL;
437+
440438
/* Drop any SSL state */
441439
pqsecure_close(conn);
442440

src/interfaces/libpq/fe-misc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ pqSendSome(PGconn *conn, int len)
898898
}
899899

900900
/* while there's still data to send */
901-
while (len > 0 || (conn->zstream && zpq_buffered(conn->zstream)))
901+
while (len > 0 || zpq_buffered(conn->zstream))
902902
{
903903
int sent;
904904
size_t processed = 0;
@@ -964,7 +964,7 @@ pqSendSome(PGconn *conn, int len)
964964
remaining -= sent;
965965
}
966966

967-
if (len > 0 || sent < 0 || (conn->zstream && zpq_buffered(conn->zstream)))
967+
if (len > 0 || sent < 0 || zpq_buffered(conn->zstream))
968968
{
969969
/*
970970
* We didn't send it all, wait till we can send more.

0 commit comments

Comments
 (0)