Skip to content

Commit

Permalink
c_api return null on null layer (#4865)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mek101 committed Jul 18, 2023
1 parent 411a098 commit 9f29a17
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,8 +1028,14 @@ ncnn_layer_t ncnn_layer_create()

ncnn_layer_t ncnn_layer_create_by_typeindex(int typeindex)
{
void* pthis = (void*)(ncnn::create_layer(typeindex));
if (!pthis)
{
return 0;
}

ncnn_layer_t layer = (ncnn_layer_t)malloc(sizeof(__ncnn_layer_t));
layer->pthis = (void*)(ncnn::create_layer(typeindex));
layer->pthis = pthis;
layer->load_param = __ncnn_layer_load_param;
layer->load_model = __ncnn_layer_load_model;
layer->create_pipeline = __ncnn_layer_create_pipeline;
Expand All @@ -1044,8 +1050,14 @@ ncnn_layer_t ncnn_layer_create_by_typeindex(int typeindex)
#if NCNN_STRING
ncnn_layer_t ncnn_layer_create_by_type(const char* type)
{
void* pthis = (void*)(ncnn::create_layer(type));
if (!pthis)
{
return 0;
}

ncnn_layer_t layer = (ncnn_layer_t)malloc(sizeof(__ncnn_layer_t));
layer->pthis = (void*)(ncnn::create_layer(type));
layer->pthis = pthis;
layer->load_param = __ncnn_layer_load_param;
layer->load_model = __ncnn_layer_load_model;
layer->create_pipeline = __ncnn_layer_create_pipeline;
Expand Down

0 comments on commit 9f29a17

Please sign in to comment.