]> granicus.if.org Git - icu/commitdiff
ICU-9326 Fix icupkg tool trap on Windows static build
authorMichael Ow <mow@svn.icu-project.org>
Thu, 17 May 2012 19:56:11 +0000 (19:56 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Thu, 17 May 2012 19:56:11 +0000 (19:56 +0000)
X-SVN-Rev: 31828

icu4c/source/tools/icupkg/icupkg.cpp
icu4c/source/tools/toolutil/pkg_icu.cpp
icu4c/source/tools/toolutil/pkg_icu.h

index eb198fdedc8f83da0f652a2c1620cbe472813e02..8001ec2ae93fb29345e1c40d514c99134bb60bdc 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2005-2010, International Business Machines
+*   Copyright (C) 2005-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -402,8 +402,12 @@ main(int argc, char *argv[]) {
 
     /* extract items */
     if(options[OPT_EXTRACT_LIST].doesOccur) {
-        listPkg=readList(NULL, options[OPT_EXTRACT_LIST].value, FALSE);
-        if(listPkg!=NULL) {
+        listPkg=new Package();
+        if(listPkg==NULL) {
+            fprintf(stderr, "icupkg: not enough memory\n");
+            exit(U_MEMORY_ALLOCATION_ERROR);
+        }
+        if(!readList(NULL, options[OPT_EXTRACT_LIST].value, FALSE, listPkg)) {
             pkg->extractItems(destPath, *listPkg, outType);
             delete listPkg;
         } else {
index 7af5b1c14188d3a1120ed02beb50f6ea3423236b..f2a2d5ffe599d2eb3c7edda11708bee872ac24a5 100644 (file)
@@ -1,5 +1,5 @@
 /******************************************************************************
- *   Copyright (C) 2008-2009, International Business Machines
+ *   Copyright (C) 2008-2012, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *******************************************************************************
  */
@@ -56,8 +56,8 @@ isListTextFile(const char *listname) {
  * Otherwise, read the file itself as a single-item list.
  */
 U_CAPI Package * U_EXPORT2
-readList(const char *filesPath, const char *listname, UBool readContents) {
-    Package *listPkg;
+readList(const char *filesPath, const char *listname, UBool readContents, Package *listPkgIn) {
+    Package *listPkg = listPkgIn;
     FILE *file;
     const char *listNameEnd;
 
@@ -66,10 +66,12 @@ readList(const char *filesPath, const char *listname, UBool readContents) {
         return NULL;
     }
 
-    listPkg=new Package();
-    if(listPkg==NULL) {
-        fprintf(stderr, "icupkg: not enough memory\n");
-        exit(U_MEMORY_ALLOCATION_ERROR);
+    if (listPkg == NULL) {
+        listPkg=new Package();
+        if(listPkg==NULL) {
+            fprintf(stderr, "icupkg: not enough memory\n");
+            exit(U_MEMORY_ALLOCATION_ERROR);
+        }
     }
 
     listNameEnd=strchr(listname, 0);
index 75e2edd02d549573a06c03e4560303ec6904cf3a..7b652cd8997b799927bc9bcd11b026be69edc054 100644 (file)
@@ -1,5 +1,5 @@
 /******************************************************************************
- *   Copyright (C) 2008-2011, International Business Machines
+ *   Copyright (C) 2008-2012, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *******************************************************************************
  */
@@ -17,6 +17,6 @@ writePackageDatFile(const char *outFilename, const char *outComment,
                     char outType);
 
 U_CAPI icu::Package * U_EXPORT2
-readList(const char *filesPath, const char *listname, UBool readContents);
+readList(const char *filesPath, const char *listname, UBool readContents, Package *listPkgIn = NULL);
 
 #endif