commit 8a53e62700c906ef970742a29fd16aaef8930cda
parent 7acafe738ad0f90619521e7e174daa739313c536
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 4 Feb 2026 17:58:55 +0100
Improve verification of molecular mixture concentrations
The concentration of a molecule cannot exceed 1.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/sln_mixture.c b/src/sln_mixture.c
@@ -215,7 +215,12 @@ parse_molecule
tk = strtok_r(NULL, " \t", &tk_ctx);
res = cstr_to_double(tk, &molecule->param.concentration);
- if(res == RES_OK && molecule->param.concentration < 0) res = RES_BAD_ARG;
+ if(res == RES_OK) {
+ if(molecule->param.concentration < 0
+ || molecule->param.concentration > 1) {
+ res = RES_BAD_ARG;
+ }
+ }
if(res != RES_OK) {
LOG(ERROR, "invalid concentration `%s'\n", tk ? tk : "(null)");
goto error;