Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9f7a855

Browse filesBrowse files
committed
fix: Use memmove to copy str_value kv_override. Closes abetlen#1417
1 parent 0a454be commit 9f7a855
Copy full SHA for 9f7a855

File tree

Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed

‎llama_cpp/llama.py

Copy file name to clipboardExpand all lines: llama_cpp/llama.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,12 @@ def __init__(
262262
raise ValueError(f"Value for {k} is too long: {v}")
263263
v_bytes = v_bytes.ljust(128, b"\0")
264264
self._kv_overrides_array[i].tag = llama_cpp.LLAMA_KV_OVERRIDE_TYPE_STR
265-
self._kv_overrides_array[i].value.str_value[:128] = v_bytes
265+
# copy min(v_bytes, 128) to str_value
266+
ctypes.memmove(
267+
self._kv_overrides_array[i].value.str_value,
268+
v_bytes,
269+
min(len(v_bytes), 128),
270+
)
266271
else:
267272
raise ValueError(f"Unknown value type for {k}: {v}")
268273

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.