From 490bb5d4310c68fe82e8532eda063bb976115cb5 Mon Sep 17 00:00:00 2001 From: juniperoserra Date: Mon, 18 Apr 2005 19:33:19 +0000 Subject: [PATCH] Fixed a bug that caused crashes with long system paths. --- build/windows/launcher/launcher.cpp | 28 ++++++++++++++++---------- build/windows/launcher/processing.exe | Bin 123829 -> 123829 bytes 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/build/windows/launcher/launcher.cpp b/build/windows/launcher/launcher.cpp index f0a882c02..d1c6eb7a1 100644 --- a/build/windows/launcher/launcher.cpp +++ b/build/windows/launcher/launcher.cpp @@ -21,7 +21,7 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) // all these malloc statements... things may need to be larger. // what was passed to this application - char *incoming_cmdline = (char *)malloc(256 * sizeof(char)); + char *incoming_cmdline = (char *)malloc(strlen(lpCmd) * sizeof(char)); strcpy (incoming_cmdline, lpCmd); // what gets put together to pass to jre @@ -38,7 +38,7 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) // remove the application name *(strrchr(loaddir, '\\')) = '\0'; - char *cp = (char *)malloc(8 * strlen(loaddir) + 200); + char *cp = (char *)malloc(8 * strlen(loaddir) + 4096); // if this code looks shitty, that's because it is. people are @@ -48,6 +48,8 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) // quotes will show up. this is a guess at dealing with the things, // without spending a whole day to make it overly robust. [fry] + + // test to see if running with a java runtime nearby or not char *testpath = (char *)malloc(MAX_PATH * sizeof(char)); @@ -58,13 +60,14 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) int local_jre_installed = (fp != NULL); //char *rt_jar = (fp == NULL) ? "" : "java\\lib\\rt.jar;"; if (fp != NULL) fclose(fp); // argh! this was probably causing trouble + //MessageBox(NULL, local_jre_installed ? // "local jre installed" : "couldn't find jre", "p5", MB_OK); //const char *envClasspath = getenv("CLASSPATH"); - char *env_classpath = (char *)malloc(256 * sizeof(char)); + char *env_classpath = (char *)malloc(16384 * sizeof(char)); // ignoring CLASSPATH for now, because it's not needed // and causes more trouble than it's worth [0060] @@ -94,7 +97,7 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) } */ - char *qtjava_path = (char *)malloc(256 * sizeof(char)); + char *qtjava_path = (char *)malloc(16384 * sizeof(char)); qtjava_path[0] = 0; if (getenv("WINDIR") == NULL) { @@ -126,7 +129,7 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) } } } - + // NO! put quotes around contents of cp, because %s might have spaces in it. // don't put quotes in it, because it's setting the environment variable // for CLASSPATH, not being included on the command line. so setting the @@ -166,21 +169,22 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) loaddir, loaddir, loaddir, loaddir, env_classpath); - //MessageBox(NULL, cp, - // "it's twoo! it's twoo!", MB_OK); + //MessageBox(NULL, cp, "it's twoo! it's twoo!", MB_OK); if (!SetEnvironmentVariable("CLASSPATH", cp)) { MessageBox(NULL, "Could not set CLASSPATH environment variable", "Processing Error", MB_OK); return 0; } + + // need to add the local jre to the path for 'java mode' in the env if (local_jre_installed) { - char *env_path = (char *)malloc(512 * sizeof(char)); + + char *env_path = (char *)malloc(strlen(getenv("PATH")) * sizeof(char)); strcpy(env_path, getenv("PATH")); - - char *paf = (char *)malloc(1024 * sizeof(char)); + char *paf = (char *)malloc((strlen(env_path) + strlen(loaddir) + 32) * sizeof(char)); sprintf(paf, "%s\\java\\bin;%s", loaddir, env_path); if (!SetEnvironmentVariable("PATH", paf)) { @@ -188,6 +192,8 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) "Processing Error", MB_OK); return 0; } + + } //MessageBox(NULL, cp, "whaadddup", MB_OK); @@ -198,7 +204,7 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) // append additional incoming stuff (document names), if any strcat(outgoing_cmdline, incoming_cmdline); - char *executable = (char *)malloc(256 * sizeof(char)); + char *executable = (char *)malloc((strlen(loaddir) + 256) * sizeof(char)); // loaddir is the name path to the current application //if (localJreInstalled) { diff --git a/build/windows/launcher/processing.exe b/build/windows/launcher/processing.exe index 3d63723d461c3f8098eda6086a67a47ea265b82e..2c5ed56ae34cf82179a71ea9c34f09ad5425379a 100755 GIT binary patch delta 2541 zcmZ`*ZBSHI7(Vai0?YF0fF+T+;9^*rRAS}mv{?+Kmdl7~rGXJ;iDI~Y_*Dv0URQGU zmZv5gaVl$?Nme(Y{9N7m(lkWWC}+gf+L9kMHjJju_Po2WEF;|?oaa2x^S*-( zwM~(=O_7eZVNTo+$F|mcQg2pG ziaAFAOU;P-7i>kB>Mhq(!ZYb_eOmYg+OEGBo<4U~v=H6}_+uZQV6q5pn0H46ycfE? z z(QiZye`g466Z%b5vfj5A)M&#|Q zxQhv12*fSO=Cy;UbjMeE^o~gDJ878Nv$yaXFzjQ44^%~$0iHGE6jncCxDLC7qlq0i z49JPj%;ek{C-Krca2qI^BsxPZKRrSY-k zbJu-7EaGp&>5Uy3(zAY>8S=)!sYN z0pUyfl%=V!_aKpT7@9HRs?Yb_b8|iR*mekbJuR1v7JE`o6=yJZbRA;5gRun#1qs}=NE*C5HFT4D&_=7gG`^**~^5{82Pt{o|R`k6iJ=(TsdyXp zeh!`F$je7*Avxu|W7MFy`(3$m(@%&CVRB?uD{aIH9C4gRvQUWIAkmIT4Mn!nvL!;a z%bMeqMcwiu4_2AdMp+M@iQ_{iaGwfZDl6v0)EOIkG*j?ZvGjYE*vg9L*~BXOUK@=} zG7Yfi!HUN2Z=-RPDKEFt0u)|wf^x9!FHg`&%#NI(XK+K)+bJhW1heu9o`Mg9h?T3_ zafPk&vv#_snBrvhNlY!$bCO0Twhr)rihor)<<*nO=ae%}VMDD_JB3ABO_G-W-J5G)iIxTK`CNH~KGuik*4u+UBvm6R?i7K?+P0^axHrJ`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