Skip to content

Commit

Permalink
Merge pull request #12 from alexarchambault/develop
Browse files Browse the repository at this point in the history
Fix off-by-one error for too long env var values
  • Loading branch information
alexarchambault committed Feb 21, 2022
2 parents e47eadb + 4abd958 commit cebc57d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.5
0.9.12
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object `windows-jni-utils-tests` extends ScalaModule with JniUtilsPublishModule
`windows-jni-utils-coursierapi`
)
def ivyDeps = Agg(Deps.utest)
def testFrameworks = Seq("utest.runner.Framework")
def testFramework = "utest.runner.Framework"
}
}

Expand Down
9 changes: 7 additions & 2 deletions settings.sc
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,18 @@ def toCrLfOpt(content: Array[Byte]): Option[Array[Byte]] = {
}
}

private def vcVersions = Seq("2019", "2017")
private def vcVersions = Seq("2022", "2019", "2017")
private def vcEditions = Seq("Enterprise", "Community", "BuildTools")
private def progFiles = Seq(
"""C:\Program Files""",
"""C:\Program Files (x86)"""
)
private lazy val vcvarsCandidates = Option(System.getenv("VCVARSALL")) ++ {
for {
progFiles0 <- progFiles
version <- vcVersions
edition <- vcEditions
} yield """C:\Program Files (x86)\Microsoft Visual Studio\""" + version + "\\" + edition + """\VC\Auxiliary\Build\vcvars64.bat"""
} yield progFiles0 + """\Microsoft Visual Studio\""" + version + "\\" + edition + """\VC\Auxiliary\Build\vcvars64.bat"""
}

private def vcvarsOpt: Option[os.Path] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ JNIEXPORT jbyteArray JNICALL Java_coursier_jniutils_DefaultNativeApi_GetUserEnvi
jbyte *data = NULL;

if (status == ERROR_SUCCESS || status == ERROR_MORE_DATA) {
if (status == ERROR_MORE_DATA) {
size = size + 1; /* ??? */
}
arr = (*env)->NewByteArray(env, size + 1);
data = (*env)->GetByteArrayElements(env, arr, NULL);

Expand Down

0 comments on commit cebc57d

Please sign in to comment.