@henningw commented on this pull request.
> + */ +static int _curl_send(const char* uri, str *post_data) +{ + int datasz; + char* send_data; + CURL *curl_handle; + CURLcode res; + // LM_DBG("sending to[%s]\n", uri); + + datasz = snprintf(NULL, 0, BODY_FMT, slack_channel, slack_username, post_data->s, slack_icon); + send_data = (char*)pkg_malloc((datasz+1)*sizeof(char)); + if(send_data==NULL) { + LM_ERR("Error: can not allocate pkg memory [%d] bytes\n", datasz); + return -1; + } + snprintf(send_data, datasz+1, BODY_FMT, slack_channel, slack_username, post_data->s, slack_icon);
This of course depends on the working of snprintf, the docs unfortunately do not give much more details. But generally it is good "defensive" programming practice to check for errors on outside library calls that you do not control/own.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.