aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex "mcmonkey" Goodwin <git_commits@alexgoodwin.dev>2023-03-12 12:33:29 -0700
committerAlex "mcmonkey" Goodwin <git_commits@alexgoodwin.dev>2023-03-12 12:33:29 -0700
commit48df6d66ea627a1c538aba4d37d9141798fff4d7 (patch)
tree1b25204aa5a0e213128e0099f2c3e674f53ea6c8
parenta71b7b5ec09a24e8a9bb3385e32862da905af6f1 (diff)
add safety check in case of short extensions
so eg if a two-letter or empty extension is used, `.txt` would break, this `max` call protects that.
-rw-r--r--modules/images.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/images.py b/modules/images.py
index 2ce5c67c..18d1de2f 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -575,7 +575,7 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
fullfn_without_extension, extension = os.path.splitext(params.filename)
if hasattr(os, 'statvfs'):
max_name_len = os.statvfs(path).f_namemax
- fullfn_without_extension = fullfn_without_extension[:max_name_len - len(extension)]
+ fullfn_without_extension = fullfn_without_extension[:max_name_len - max(4, len(extension))]
params.filename = fullfn_without_extension + extension
_atomically_save_image(image, fullfn_without_extension, extension)