Skip to content

Commit 9d1955f

Browse files
committed
sources.py: fix unconditional return in map value clone
In the generated C code for cloning the object values of a mapStringObject, an 'if' statement checking for cloning failure was followed by an erroneous semicolon. This caused the 'if' to have an empty body, leading to the subsequent 'return NULL;' being executed unconditionally in the first iteration of the value-cloning loop if the map was not empty. Consequently, cloning a mapStringObject with one or more elements would always fail prematurely when this specific path for object-values was taken. Removing the semicolon makes the 'return NULL;' conditional upon actual cloning failure, as intended. Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent d559a4c commit 9d1955f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ocispec/sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ def make_clone(obj, c_file, prefix):
881881
c_file.append(f" for (i = 0; i < src->len; i++)\n")
882882
c_file.append(" {\n")
883883
c_file.append(f" ret->{i.fixname}[i] = clone_{node_name} (src->{i.fixname}[i]);\n")
884-
c_file.append(f" if (ret->{i.fixname}[i] == NULL);\n")
884+
c_file.append(f" if (ret->{i.fixname}[i] == NULL)\n")
885885
c_file.append(f" return NULL;\n")
886886
c_file.append(" }\n")
887887
c_file.append(f" }}\n")

0 commit comments

Comments
 (0)