fix [-Werror=format-security]

This commit is contained in:
Remi Collet
2020-06-22 12:54:12 +02:00
parent 8f424195e0
commit 912ab43641
4 changed files with 9 additions and 10 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
} }
} catch (exception& e) } catch (exception& e)
{ {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what()); zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
return; return;
} }
} }
+2 -3
View File
@@ -42,7 +42,7 @@ PHP_METHOD(CnnFaceDetection, __construct)
deserialize(cnn_face_detection_model_path) >> *pnet; deserialize(cnn_face_detection_model_path) >> *pnet;
cfd->net = pnet; cfd->net = pnet;
} catch (exception& e) { } catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what()); zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
return; return;
} }
} }
@@ -77,7 +77,6 @@ PHP_METHOD(CnnFaceDetection, detect)
net_type *pnet = cfd->net; net_type *pnet = cfd->net;
auto dets = (*pnet)(img); auto dets = (*pnet)(img);
int rect_count = 0;
array_init(return_value); array_init(return_value);
// Scale the detection locations back to the original image size // Scale the detection locations back to the original image size
@@ -101,7 +100,7 @@ PHP_METHOD(CnnFaceDetection, detect)
} }
catch (exception& e) catch (exception& e)
{ {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what()); zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
return; return;
} }
} }
+4 -4
View File
@@ -52,7 +52,7 @@ PHP_FUNCTION(dlib_face_landmark_detection)
zval ARRAY_NAME_WITH_INDEX(face, j); zval ARRAY_NAME_WITH_INDEX(face, j);
array_init(&ARRAY_NAME_WITH_INDEX(face, j)); array_init(&ARRAY_NAME_WITH_INDEX(face, j));
for (int k = 0; k < shape.num_parts(); k++) { for (unsigned int k = 0; k < shape.num_parts(); k++) {
zval ARRAY_NAME_WITH_INDEX(part, k); zval ARRAY_NAME_WITH_INDEX(part, k);
array_init(&ARRAY_NAME_WITH_INDEX(part, k)); array_init(&ARRAY_NAME_WITH_INDEX(part, k));
dlib::point p = shape.part(k); dlib::point p = shape.part(k);
@@ -95,7 +95,7 @@ PHP_METHOD(FaceLandmarkDetection, __construct)
fld->sp = new shape_predictor; fld->sp = new shape_predictor;
deserialize(shape_predictor_file_path) >> *(fld->sp); deserialize(shape_predictor_file_path) >> *(fld->sp);
} catch (exception& e) { } catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what()); zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
return; return;
} }
} }
@@ -151,7 +151,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
array_init(&rect_arr); array_init(&rect_arr);
array_init(&parts_arr); array_init(&parts_arr);
for (int i = 0; i < shape.num_parts(); i++) { for (unsigned int i = 0; i < shape.num_parts(); i++) {
zval part; zval part;
array_init(&part); array_init(&part);
dlib::point p = shape.part(i); dlib::point p = shape.part(i);
@@ -169,7 +169,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
add_assoc_zval(return_value, "rect", &rect_arr); add_assoc_zval(return_value, "rect", &rect_arr);
add_assoc_zval(return_value, "parts", &parts_arr); add_assoc_zval(return_value, "parts", &parts_arr);
} catch (exception& e) { } catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what()); zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
return; return;
} }
} }
+2 -2
View File
@@ -37,7 +37,7 @@ PHP_METHOD(FaceRecognition, __construct)
fr->net = new anet_type; fr->net = new anet_type;
deserialize(face_recognition_model_path) >> *(fr->net); deserialize(face_recognition_model_path) >> *(fr->net);
} catch (exception& e) { } catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what()); zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
return; return;
} }
} }
@@ -183,7 +183,7 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
add_next_index_double(return_value, d); add_next_index_double(return_value, d);
} }
} catch (exception& e) { } catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what()); zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
return; return;
} }
} }