|
1 |
| -#include <string.h> |
2 | 1 | #include <Python.h>
|
3 | 2 | #include <sass/context.h>
|
4 | 3 |
|
@@ -461,8 +460,8 @@ static Sass_Import_List _call_py_importer_f(
|
461 | 460 | /* We need to give copies of these arguments; libsass handles
|
462 | 461 | * deallocation of them later, whereas path_str is left flapping
|
463 | 462 | * in the breeze -- it's treated const, so that's okay. */
|
464 |
| - if (source_str) source_str = strdup(source_str); |
465 |
| - if (sourcemap_str) sourcemap_str = strdup(sourcemap_str); |
| 463 | + if (source_str) source_str = sass_copy_c_string(source_str); |
| 464 | + if (sourcemap_str) sourcemap_str = sass_copy_c_string(sourcemap_str); |
466 | 465 |
|
467 | 466 | sass_imports[i] = sass_make_import_entry(
|
468 | 467 | path_str, source_str, sourcemap_str
|
@@ -527,7 +526,7 @@ PySass_compile_string(PyObject *self, PyObject *args) {
|
527 | 526 | return NULL;
|
528 | 527 | }
|
529 | 528 |
|
530 |
| - context = sass_make_data_context(strdup(string)); |
| 529 | + context = sass_make_data_context(sass_copy_c_string(string)); |
531 | 530 | options = sass_data_context_get_options(context);
|
532 | 531 | sass_option_set_output_style(options, output_style);
|
533 | 532 | sass_option_set_source_comments(options, source_comments);
|
@@ -578,11 +577,8 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
|
578 | 577 | if (PyBytes_Check(source_map_filename)) {
|
579 | 578 | size_t source_map_file_len = PyBytes_GET_SIZE(source_map_filename);
|
580 | 579 | if (source_map_file_len) {
|
581 |
| - char *source_map_file = (char *) malloc(source_map_file_len + 1); |
582 |
| - strncpy( |
583 |
| - source_map_file, |
584 |
| - PyBytes_AS_STRING(source_map_filename), |
585 |
| - source_map_file_len + 1 |
| 580 | + char *source_map_file = sass_copy_c_string( |
| 581 | + PyBytes_AS_STRING(source_map_filename) |
586 | 582 | );
|
587 | 583 | sass_option_set_source_map_file(options, source_map_file);
|
588 | 584 | }
|
|
0 commit comments