aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/common/dialyzer.c
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2016-04-11 16:40:38 +0200
committerBjörn-Egil Dahlberg <[email protected]>2016-04-11 16:40:38 +0200
commit7db616041e97e88cac64d13ab5289c3d64698382 (patch)
tree1dfd34e1891a601098512d65c84f5639a8dfbcf5 /erts/etc/common/dialyzer.c
parent8cda28dea9595c29a2b3b61d4a6dab43977b178a (diff)
parent9194e3beb7170c7a3db7391f005e6ab0aabd180d (diff)
downloadotp-7db616041e97e88cac64d13ab5289c3d64698382.tar.gz
otp-7db616041e97e88cac64d13ab5289c3d64698382.tar.bz2
otp-7db616041e97e88cac64d13ab5289c3d64698382.zip
Merge branch 'msantos/erts/cli-abort-on-alloc-fail/PR-948/OTP-13486'
* msantos/erts/cli-abort-on-alloc-fail/PR-948/OTP-13486: erts/common: check for OOM on Windows
Diffstat (limited to 'erts/etc/common/dialyzer.c')
-rw-r--r--erts/etc/common/dialyzer.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/erts/etc/common/dialyzer.c b/erts/etc/common/dialyzer.c
index c45626606c..8ee2db7e3f 100644
--- a/erts/etc/common/dialyzer.c
+++ b/erts/etc/common/dialyzer.c
@@ -63,13 +63,14 @@ static int eargc; /* Number of arguments in eargv. */
*/
static void error(char* format, ...);
-static char* emalloc(size_t size);
+static void* emalloc(size_t size);
static char* strsave(char* string);
static void push_words(char* src);
static int run_erlang(char* name, char** argv);
static char* get_default_emulator(char* progname);
#ifdef __WIN32__
static char* possibly_quote(char* arg);
+static void* erealloc(void *p, size_t size);
#endif
/*
@@ -164,10 +165,10 @@ int main(int argc, char** argv)
#ifdef __WIN32__
int len;
/* Convert argv to utf8 */
- argv = malloc((argc+1) * sizeof(char*));
+ argv = emalloc((argc+1) * sizeof(char*));
for (i=0; i<argc; i++) {
len = WideCharToMultiByte(CP_UTF8, 0, wcargv[i], -1, NULL, 0, NULL, NULL);
- argv[i] = malloc(len*sizeof(char));
+ argv[i] = emalloc(len*sizeof(char));
WideCharToMultiByte(CP_UTF8, 0, wcargv[i], -1, argv[i], len, NULL, NULL);
}
argv[argc] = NULL;
@@ -310,7 +311,7 @@ wchar_t *make_commandline(char **argv)
buff = (wchar_t *) emalloc(siz*sizeof(wchar_t));
} else if (siz < num) {
siz = num;
- buff = (wchar_t *) realloc(buff,siz*sizeof(wchar_t));
+ buff = (wchar_t *) erealloc(buff,siz*sizeof(wchar_t));
}
p = buff;
num=0;
@@ -413,15 +414,26 @@ error(char* format, ...)
exit(1);
}
-static char*
+static void*
emalloc(size_t size)
{
- char *p = malloc(size);
+ void *p = malloc(size);
if (p == NULL)
error("Insufficient memory");
return p;
}
+#ifdef __WIN32__
+static void *
+erealloc(void *p, size_t size)
+{
+ void *res = realloc(p, size);
+ if (res == NULL)
+ error("Insufficient memory");
+ return res;
+}
+#endif
+
static char*
strsave(char* string)
{