aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2003-04-29 07:15:25 +0000
committerWerner Koch <[email protected]>2003-04-29 07:15:25 +0000
commitd1749206912181e1747dc0123fa3a04c6011eda8 (patch)
treef10a1b36fcddff54b18e1b79aac8d29c9764acc9
parent* build-packet.c (build_sig_subpkt): Comments. (diff)
downloadgnupg-d1749206912181e1747dc0123fa3a04c6011eda8.tar.gz
gnupg-d1749206912181e1747dc0123fa3a04c6011eda8.zip
* filter.h: Remove const from WHAT.
* progress.c (handle_progress): Store a copy of NAME. (progress_filter): Release WHAT, make sure not to print a NULL WHAT. * openfile.c (open_sigfile): Adjust free for new progress semantics. * plaintext.c (ask_for_detached_datafile): Don't dealloc pfx->WHAT.
-rw-r--r--g10/ChangeLog8
-rw-r--r--g10/filter.h2
-rw-r--r--g10/openfile.c3
-rw-r--r--g10/plaintext.c6
-rw-r--r--g10/progress.c18
5 files changed, 25 insertions, 12 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 7cd33b5fd..0a382e99a 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,11 @@
+2003-04-28 Werner Koch <[email protected]>
+
+ * filter.h: Remove const from WHAT.
+ * progress.c (handle_progress): Store a copy of NAME.
+ (progress_filter): Release WHAT, make sure not to print a NULL WHAT.
+ * openfile.c (open_sigfile): Adjust free for new progress semantics.
+ * plaintext.c (ask_for_detached_datafile): Don't dealloc pfx->WHAT.
+
2003-04-28 David Shaw <[email protected]>
* build-packet.c (build_sig_subpkt): Comments.
diff --git a/g10/filter.h b/g10/filter.h
index d420d7c62..9f235fd6b 100644
--- a/g10/filter.h
+++ b/g10/filter.h
@@ -110,7 +110,7 @@ typedef struct {
typedef struct {
- const char *what; /* description */
+ char *what; /* description */
u32 last_time; /* last time reported */
unsigned long last; /* last amount reported */
unsigned long offset; /* current amount */
diff --git a/g10/openfile.c b/g10/openfile.c
index b1fd98ea9..3306e2f7d 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -284,8 +284,7 @@ open_sigfile( const char *iname, progress_filter_context_t *pfx )
log_info(_("assuming signed data in `%s'\n"), buf );
if (a && pfx)
handle_progress (pfx, a, buf);
- else
- m_free(buf);
+ m_free(buf);
}
}
return a;
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 2567a7613..96d916679 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -328,14 +328,11 @@ ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2,
const char *inname, int textmode )
{
progress_filter_context_t pfx;
- int dealloc_pfx_name = 1;
char *answer = NULL;
IOBUF fp;
int rc = 0;
fp = open_sigfile( inname, &pfx ); /* open default file */
- if (!fp)
- dealloc_pfx_name = 0;
if( !fp && !opt.batch ) {
int any=0;
@@ -370,8 +367,6 @@ ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2,
}
do_hash( md, md2, fp, textmode );
iobuf_close(fp);
- if (dealloc_pfx_name)
- m_free ((void *)pfx.what);
leave:
m_free(answer);
@@ -398,7 +393,6 @@ hash_datafiles( MD_HANDLE md, MD_HANDLE md2, STRLIST files,
if( fp ) {
do_hash( md, md2, fp, textmode );
iobuf_close(fp);
- m_free ((void *)pfx.what);
return 0;
}
log_error (_("no signed data\n"));
diff --git a/g10/progress.c b/g10/progress.c
index 707163dca..4d873eea9 100644
--- a/g10/progress.c
+++ b/g10/progress.c
@@ -45,7 +45,9 @@ progress_filter (void *opaque, int control,
pfx->offset = 0;
pfx->last_time = make_timestamp ();
- sprintf (buffer, "%.20s ? %lu %lu", pfx->what, pfx->offset,
+ sprintf (buffer, "%.20s ? %lu %lu",
+ pfx->what? pfx->what : "?",
+ pfx->offset,
pfx->total);
write_status_text (STATUS_PROGRESS, buffer);
}
@@ -69,7 +71,9 @@ progress_filter (void *opaque, int control,
{
char buffer[50];
- sprintf (buffer, "%.20s ? %lu %lu", pfx->what, pfx->offset,
+ sprintf (buffer, "%.20s ? %lu %lu",
+ pfx->what? pfx->what : "?",
+ pfx->offset,
pfx->total);
write_status_text (STATUS_PROGRESS, buffer);
@@ -77,6 +81,14 @@ progress_filter (void *opaque, int control,
pfx->last_time = timestamp;
}
}
+ else if (control == IOBUFCTRL_FREE)
+ {
+ /* Note, that we must always dealloc resources of a filter
+ within the filter handler and not anywhere else. (We set it
+ to NULL and check all uses just in case.) */
+ m_free (pfx->what);
+ pfx->what = NULL;
+ }
else if (control == IOBUFCTRL_DESC)
*(char**)buf = "progress_filter";
return rc;
@@ -99,7 +111,7 @@ handle_progress (progress_filter_context_t *pfx, IOBUF inp, const char *name)
filesize = opt.set_filesize;
/* register the progress filter */
- pfx->what = name ? name : "stdin";
+ pfx->what = m_strdup (name ? name : "stdin");
pfx->total = filesize;
iobuf_push_filter (inp, progress_filter, pfx);
}