jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
changeset 2602 5b394a4b6ce1
parent 2 90ce3da70b43
child 2624 1ae5a9028dd4
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp	Thu Oct 09 21:12:56 2008 +0100
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp	Fri Oct 17 09:43:30 2008 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,14 +46,13 @@
 
 #include "unpack.h"
 
-void* must_malloc(int size) {
-  int msize = size;
-  assert(size >= 0);
+void* must_malloc(size_t size) {
+  size_t msize = size;
   #ifdef USE_MTRACE
-  if (msize < sizeof(int))
+  if (msize >= 0 && msize < sizeof(int))
     msize = sizeof(int);  // see 0xbaadf00d below
   #endif
-  void* ptr = malloc(msize);
+  void* ptr = (msize > PSIZE_MAX) ? null : malloc(msize);
   if (ptr != null) {
     memset(ptr, 0, size);
   } else {