diff --git a/src/p_armpe.cpp b/src/p_armpe.cpp index ff1168ef..c4f10a6d 100644 --- a/src/p_armpe.cpp +++ b/src/p_armpe.cpp @@ -1338,12 +1338,13 @@ upx_byte *Resource::build() void Resource::destroy(upx_rnode *node,unsigned level) { delete [] node->name; node->name = NULL; - if (level == 3) - return; - upx_rbranch * const branch = (upx_rbranch *) node; - for (int ic = branch->nc; --ic >= 0; ) - destroy(branch->children[ic],level + 1); - delete [] branch->children; branch->children = NULL; + if (level != 3) + { + upx_rbranch * const branch = (upx_rbranch *) node; + for (int ic = branch->nc; --ic >= 0; ) + destroy(branch->children[ic],level + 1); + delete [] branch->children; branch->children = NULL; + } } static void lame_print_unicode(const upx_byte *p) diff --git a/src/p_w32pe.cpp b/src/p_w32pe.cpp index fcd4147a..c65d3c3d 100644 --- a/src/p_w32pe.cpp +++ b/src/p_w32pe.cpp @@ -1298,12 +1298,14 @@ upx_byte *Resource::build() void Resource::destroy(upx_rnode *node,unsigned level) { delete [] node->name; node->name = NULL; - if (level == 3) - return; - upx_rbranch * const branch = (upx_rbranch *) node; - for (int ic = branch->nc; --ic >= 0; ) - destroy(branch->children[ic],level + 1); - delete [] branch->children; branch->children = NULL; + if (level != 3) + { + upx_rbranch * const branch = (upx_rbranch *) node; + for (int ic = branch->nc; --ic >= 0; ) + destroy(branch->children[ic],level + 1); + delete [] branch->children; branch->children = NULL; + } + delete node; } static void lame_print_unicode(const upx_byte *p)