Skip to content

Commit

Permalink
db_perlvdb: unref in case of error
Browse files Browse the repository at this point in the history
(cherry picked from commit 927ddcf)
  • Loading branch information
miconda committed Jun 21, 2018
1 parent e2aa0e4 commit 5abf68b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/modules/db_perlvdb/perlvdb_conv.c
Expand Up @@ -263,9 +263,9 @@ int perlresult2dbres(SV *perlres, db1_res_t **r) {
/* Fetch column definitions */
colarrayref = perlvdb_perlmethod(perlres, PERL_VDB_COLDEFSMETHOD,
NULL, NULL, NULL, NULL);
if (!(SvROK(colarrayref))) goto error;
if (colarrayref==NULL || !(SvROK(colarrayref))) goto error;
colarray = (AV *)SvRV(colarrayref);
if (!(SvTYPE(colarray) == SVt_PVAV)) goto error;
if (colarray==NULL || !(SvTYPE(colarray) == SVt_PVAV)) goto error;

colcount = av_len(colarray) + 1;

Expand Down Expand Up @@ -305,7 +305,7 @@ int perlresult2dbres(SV *perlres, db1_res_t **r) {
}

rowarray = (AV *)SvRV(rowarrayref);
if (!(SvTYPE(rowarray) == SVt_PVAV)) goto error;
if (rowarray == NULL || !(SvTYPE(rowarray) == SVt_PVAV)) goto error;

rowcount = av_len(rowarray) + 1;

Expand Down Expand Up @@ -403,10 +403,12 @@ int perlresult2dbres(SV *perlres, db1_res_t **r) {
}

end:
if (colarray) av_undef(colarray);
if(colarray) av_undef(colarray);
if (rowarray) av_undef(rowarray);
return retval;
error:
if(colarray) av_undef(colarray);
if (rowarray) av_undef(rowarray);
LM_CRIT("broken result set. Exiting, leaving Kamailio in unknown state.\n");
return -1;
}
Expand Down

0 comments on commit 5abf68b

Please sign in to comment.