Skip to content

Commit a69f5e1

Browse files
committed
Fix: Free CPE COPY/INSERT buffers on error
1 parent c982612 commit a69f5e1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/manage_sql_secinfo.c

+27
Original file line numberDiff line numberDiff line change
@@ -2789,6 +2789,11 @@ update_scap_cpes_from_json_file (const gchar *path, gboolean use_copy)
27892789
gvm_json_pull_parser_cleanup (&parser);
27902790
cJSON_Delete (entry);
27912791
fclose (cpe_file);
2792+
if (use_copy)
2793+
db_copy_buffer_cleanup (&copy_buffer);
2794+
else
2795+
inserts_free (&inserts);
2796+
inserts_free (&deprecated_by_inserts);
27922797
sql_commit ();
27932798
return -1;
27942799
}
@@ -2803,6 +2808,11 @@ update_scap_cpes_from_json_file (const gchar *path, gboolean use_copy)
28032808
gvm_json_pull_parser_cleanup (&parser);
28042809
cJSON_Delete (entry);
28052810
fclose (cpe_file);
2811+
if (use_copy)
2812+
db_copy_buffer_cleanup (&copy_buffer);
2813+
else
2814+
inserts_free (&inserts);
2815+
inserts_free (&deprecated_by_inserts);
28062816
sql_commit ();
28072817
return -1;
28082818
}
@@ -2817,6 +2827,11 @@ update_scap_cpes_from_json_file (const gchar *path, gboolean use_copy)
28172827
sql_commit ();
28182828
gvm_json_pull_parser_cleanup (&parser);
28192829
fclose (cpe_file);
2830+
if (use_copy)
2831+
db_copy_buffer_cleanup (&copy_buffer);
2832+
else
2833+
inserts_free (&inserts);
2834+
inserts_free (&deprecated_by_inserts);
28202835
return -1;
28212836
}
28222837
}
@@ -2892,6 +2907,10 @@ update_scap_cpes_from_json_file (const gchar *path, gboolean use_copy)
28922907
gvm_json_pull_parser_cleanup (&parser);
28932908
cJSON_Delete (entry);
28942909
fclose (cpe_file);
2910+
if (use_copy)
2911+
db_copy_buffer_cleanup (&copy_buffer);
2912+
else
2913+
inserts_free (&inserts);
28952914
sql_commit ();
28962915
return -1;
28972916
}
@@ -2902,6 +2921,10 @@ update_scap_cpes_from_json_file (const gchar *path, gboolean use_copy)
29022921
gvm_json_pull_parser_cleanup (&parser);
29032922
cJSON_Delete (entry);
29042923
fclose (cpe_file);
2924+
if (use_copy)
2925+
db_copy_buffer_cleanup (&copy_buffer);
2926+
else
2927+
inserts_free (&inserts);
29052928
sql_commit ();
29062929
return -1;
29072930
}
@@ -2915,6 +2938,10 @@ update_scap_cpes_from_json_file (const gchar *path, gboolean use_copy)
29152938
sql_commit ();
29162939
gvm_json_pull_parser_cleanup (&parser);
29172940
fclose (cpe_file);
2941+
if (use_copy)
2942+
db_copy_buffer_cleanup (&copy_buffer);
2943+
else
2944+
inserts_free (&inserts);
29182945
return -1;
29192946
}
29202947
}

0 commit comments

Comments
 (0)