mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Extend free_packet to handle a packet parser context.
* g10/packet.h (struct parse_packet_ctx_s): Add fields LAST_PKT and FREE_LAST_PKT. (init_parse_packet): Clear them. (deinit_parse_packet): New macro. Change all users if init_parse_packet to also call this macro. * g10/free-packet.c (free_packet): Add arg PARSECTX and handle shallow packet copies in the context. Change all callers. * g10/parse-packet.c (parse): Store certain packets in the parse context. -- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
ba57f8302a
commit
afa8680908
12 changed files with 124 additions and 53 deletions
|
@ -394,18 +394,40 @@ free_plaintext( PKT_plaintext *pt )
|
|||
xfree (pt);
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Free the packet in PKT.
|
||||
*/
|
||||
void
|
||||
free_packet (PACKET *pkt)
|
||||
free_packet (PACKET *pkt, parse_packet_ctx_t parsectx)
|
||||
{
|
||||
if (!pkt || !pkt->pkt.generic)
|
||||
return;
|
||||
{
|
||||
if (parsectx && parsectx->last_pkt)
|
||||
{
|
||||
if (parsectx->free_last_pkt)
|
||||
{
|
||||
free_packet (parsectx->last_pkt, NULL);
|
||||
parsectx->free_last_pkt = 0;
|
||||
}
|
||||
parsectx->last_pkt = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (DBG_MEMORY)
|
||||
log_debug ("free_packet() type=%d\n", pkt->pkttype);
|
||||
|
||||
/* If we have a parser context holding PKT then do not free the
|
||||
* packet but set a flag that the packet in the parser context is
|
||||
* now a deep copy. */
|
||||
if (parsectx && parsectx->last_pkt == pkt && !parsectx->free_last_pkt)
|
||||
{
|
||||
parsectx->free_last_pkt = 1;
|
||||
pkt->pkt.generic = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pkt->pkttype)
|
||||
{
|
||||
case PKT_SIGNATURE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue