|
|
7975502 |
From d72956a6de228c91d1fc48fd15448fadea9ab6cf Mon Sep 17 00:00:00 2001
|
|
|
7975502 |
From: Frank Richter <frank.richter@gmail.com>
|
|
|
7975502 |
Date: Sat, 10 Mar 2018 14:08:37 +0100
|
|
|
7975502 |
Subject: [PATCH] wrestool: Fix get_resource_id_quoted() to return
|
|
|
7975502 |
heap-allocated string
|
|
|
7975502 |
|
|
|
7975502 |
---
|
|
|
7975502 |
NEWS | 4 ++++
|
|
|
7975502 |
wrestool/restable.c | 21 +++++++++++++--------
|
|
|
7975502 |
2 files changed, 17 insertions(+), 8 deletions(-)
|
|
|
7975502 |
|
|
|
7975502 |
diff --git a/NEWS b/NEWS
|
|
|
7975502 |
index 414bec4..086f8dc 100644
|
|
|
7975502 |
--- a/NEWS
|
|
|
7975502 |
+++ b/NEWS
|
|
|
7975502 |
@@ -1,3 +1,7 @@
|
|
|
7975502 |
+2018-??-??:
|
|
|
7975502 |
+ wrestool: Fix get_resource_id_quoted() to return heap-allocated string.
|
|
|
7975502 |
+ Found by Jonathan Liu.
|
|
|
7975502 |
+
|
|
|
7975502 |
2018-03-07: icoutils 0.32.3 released.
|
|
|
7975502 |
Fixed a segfault. (Martin Gieseking, Savannah bug 52319)
|
|
|
7975502 |
Updated Gnulib stuff.
|
|
|
7975502 |
diff --git a/wrestool/restable.c b/wrestool/restable.c
|
|
|
7975502 |
index 0d47d94..4d99687 100644
|
|
|
7975502 |
--- a/wrestool/restable.c
|
|
|
7975502 |
+++ b/wrestool/restable.c
|
|
|
7975502 |
@@ -23,6 +23,7 @@
|
|
|
7975502 |
#define N_(s) gettext_noop(s)
|
|
|
7975502 |
#include "common/intutil.h"
|
|
|
7975502 |
#include "xalloc.h" /* Gnulib */
|
|
|
7975502 |
+#include "xvasprintf.h" /* Gnulib */
|
|
|
7975502 |
#include "minmax.h" /* Gnulib */
|
|
|
7975502 |
#include "common/error.h"
|
|
|
7975502 |
#include "wrestool.h"
|
|
|
7975502 |
@@ -125,6 +126,7 @@ print_resources_callback (WinLibrary *fi, WinResource *wr,
|
|
|
7975502 |
const char *type, *offset;
|
|
|
7975502 |
int32_t id;
|
|
|
7975502 |
size_t size;
|
|
|
7975502 |
+ char *type_quoted, *name_quoted, *lang_quoted;
|
|
|
7975502 |
|
|
|
7975502 |
/* get named resource type if possible */
|
|
|
7975502 |
type = NULL;
|
|
|
7975502 |
@@ -136,28 +138,31 @@ print_resources_callback (WinLibrary *fi, WinResource *wr,
|
|
|
7975502 |
if (offset == NULL)
|
|
|
7975502 |
return;
|
|
|
7975502 |
|
|
|
7975502 |
+ type_quoted = get_resource_id_quoted(type_wr);
|
|
|
7975502 |
+ name_quoted = get_resource_id_quoted(name_wr);
|
|
|
7975502 |
+ lang_quoted = get_resource_id_quoted(lang_wr);
|
|
|
7975502 |
printf(_("--type=%s --name=%s%s%s [%s%s%soffset=0x%x size=%zu]\n"),
|
|
|
7975502 |
- get_resource_id_quoted(type_wr),
|
|
|
7975502 |
- get_resource_id_quoted(name_wr),
|
|
|
7975502 |
+ type_quoted,
|
|
|
7975502 |
+ name_quoted,
|
|
|
7975502 |
(lang_wr->id[0] != '\0' ? _(" --language=") : ""),
|
|
|
7975502 |
- get_resource_id_quoted(lang_wr),
|
|
|
7975502 |
+ lang_quoted,
|
|
|
7975502 |
(type != NULL ? "type=" : ""),
|
|
|
7975502 |
(type != NULL ? type : ""),
|
|
|
7975502 |
(type != NULL ? " " : ""),
|
|
|
7975502 |
(uint32_t) (offset - fi->memory), size);
|
|
|
7975502 |
+ free(type_quoted);
|
|
|
7975502 |
+ free(name_quoted);
|
|
|
7975502 |
+ free(lang_quoted);
|
|
|
7975502 |
}
|
|
|
7975502 |
|
|
|
7975502 |
/* return the resource id quoted if it's a string, otherwise just return it */
|
|
|
7975502 |
static char *
|
|
|
7975502 |
get_resource_id_quoted (WinResource *wr)
|
|
|
7975502 |
{
|
|
|
7975502 |
- static char tmp[WINRES_ID_MAXLEN+2];
|
|
|
7975502 |
-
|
|
|
7975502 |
if (wr->numeric_id || wr->id[0] == '\0')
|
|
|
7975502 |
- return wr->id;
|
|
|
7975502 |
+ return xstrdup(wr->id);
|
|
|
7975502 |
|
|
|
7975502 |
- sprintf(tmp, "'%s'", wr->id);
|
|
|
7975502 |
- return tmp;
|
|
|
7975502 |
+ return xasprintf("'%s'", wr->id);
|
|
|
7975502 |
}
|
|
|
7975502 |
|
|
|
7975502 |
static bool
|
|
|
7975502 |
--
|
|
|
7975502 |
2.13.2
|
|
|
7975502 |
|