@@ -375,7 +375,7 @@ static GQueue* redis_call_media_try_read_sdes(const char* prefix, JsonObject *js
375
375
* if its the second or later element. That code is fscking insane */
376
376
GQueue * out = NULL ;
377
377
redis_call_media_sdes_t * sdesref = NULL ;
378
- str * testfield = NULL ;
378
+ str * testfield = NULL , * prefixfield = NULL ;
379
379
int idx ;
380
380
381
381
/* check if we have any sdes for prefix */
@@ -393,10 +393,17 @@ static GQueue* redis_call_media_try_read_sdes(const char* prefix, JsonObject *js
393
393
g_queue_push_tail (out , sdesref );
394
394
for (idx = 1 ; ; idx ++ ) {
395
395
free (testfield );
396
- testfield = str_sprintf ("%s-%u" , prefix , idx );
397
- sdesref = redis_call_media_sdes_create (testfield -> s , json );
398
- if (!sdesref ) /* no more crypto params */
396
+ prefixfield = str_sprintf ("%s-%u" , prefix , idx );
397
+ /* check if we have more sdes for prefix */
398
+ testfield = str_sprintf ("%s_tag" , prefixfield -> s );
399
+ if (!json_object_has_member (json , testfield -> s ))
400
+ goto done ; /* nope */
401
+ sdesref = redis_call_media_sdes_create (prefixfield -> s , json );
402
+ if (!sdesref ) {
403
+ ilog (LOG_WARNING , "crypto params %s are broken" , prefixfield -> s );
399
404
break ;
405
+ }
406
+ free (prefixfield );
400
407
g_queue_push_tail (out , sdesref );
401
408
}
402
409
@@ -411,6 +418,8 @@ static GQueue* redis_call_media_try_read_sdes(const char* prefix, JsonObject *js
411
418
done :
412
419
if (testfield )
413
420
free (testfield );
421
+ if (prefixfield )
422
+ free (prefixfield );
414
423
return out ;
415
424
}
416
425
0 commit comments